Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Tree Walking question

Tree Walking question

From: Michael Chambers <michael.chambers_at_vf.vodafone.co.uk>
Date: Wed, 15 Apr 1998 19:59:58 +0100
Message-ID: <353503AE.5931EDD4@vf.vodafone.co.uk>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US