Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Tree Walking question
Does anyone know a way to do a tree walk so that instead of returning
the immediate parent for each row, the root node is always returned (or
more specifically, is returned if the parent is null).
e.g. something like
SELECT child, nvl(parent, PRIOR parent) root_node
FROM table
CONNECT BY
PRIOR child = parent
START WITH
parent IS NOT NULL;
This works for one level of hierarchy, i.e. returns the grandparent if the parent is null. I want to continue this for further levels, i.e. return the great-grandparent if parent & grandparent are null.
Thanks in advance,
Mike Chambers
Received on Wed Apr 15 1998 - 13:59:58 CDT