Re: How to control order of siblings in a tree walked by "connect by"??

From: craig sivils <casivils_at_lescsse.jsc.nasa.gov>
Date: 17 Mar 93 21:19:57 GMT
Message-ID: <casivils.732403197_at_node_508ba>


In <1993Mar17.001028.14189_at_dlogics.com> brown_at_dlogics.com (Steve Brown) writes:

>I cannot find any reference on how to control the ordering of rows at the
>same level. An example is a hierarchical parts list where I want to order
>all parts at the same level alphabetically. The "connect by" seems to use
>the order of the rows as they were loaded into the table. I didn't
>think a relational database knew/controlled the order of rows.
 

>A recursive c program to do this isn't difficult, but it doesn't return a
>single, neat, ordered result set and probably would require a cursor per level.
 

>I'm probably missing something. Any hints, ideas, or references greatly
>appreciated.

You can but you can't. Let me explain, In SQL you can't, but due to the way SQL is implemented, you can. You need to correctly index the table so that the index used for the connect by will order rows on the same level alphabetically. Usually done by indexing the key column first then the alphabetical column next. Since Oracle goes down the index to find the rows it will retrieve them in alphabetical order. If you wish to dynamically order them well......

                                 Craig
Received on Wed Mar 17 1993 - 22:19:57 CET

Original text of this message