![]() | |
#1
| |||
| |||
|
|
If I'm using a procedural language, I can implement this by recursion: starting with the given object, search upwards for parents until there are no more. I don't see how to do this with a SELECT statement. Is there some SQL/SELECT construct that I'm overlooking? |
#2
| |||
| |||
|
|
Oracle has had a "CONNECT BY" structure to handle network/graph problems; it has never been standardized. |
#3
| |||
| |||
|
|
select * from hier_tab start with id=x connect by prior id=parent 'prior id' means the one coming 'before' the child, which is the parent, i.e. in this fashion you search from child to parent. you can also search from parent to all its descendants (children, grand children etc): select * from hier_tab start with id=x connect by prior parent=id will give you the entire tree below some parent |
#4
| |||
| |||
|
|
You are confused -- the way 'connect by' behaves in your examples is just the opposite to what you've described. |
#5
| |||
| |||
|
|
On 2006-03-21, vc <boston103 (AT) hotmail (DOT) com> wrote: You are confused -- the way 'connect by' behaves in your examples is just the opposite to what you've described. Indeed. The DB2 solution using WITH, doesn't work for oracle b.t.w.: the result is ORA-32031: illegal reference of a query name in WITH clause. |
![]() |
| Thread Tools | |
| Display Modes | |
| |