Monday, August 23, 2010

Very basic Oracle query to get parent hierarchy

0 comments
Here's a simple query that uses the "connect by" functionality in Oracle to get the entire parental hierarchy of a given nodeid in DTREE.

select *
from dtree
connect by prior parentid=dataid
start with dataid = 12345 --starting nodeID

This will give you all the parent nodeid's starting from the Enterprise top level down to the dataid you specified.