Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

leaf node Hierarchy based on tree position

679884Jan 14 2009 — edited Jan 14 2009
Hi All,

I need to find the Hierarchy of given leaf node. Can you please help me. Here are details

create table t_rk_4 (child_id number, parent_id number, treenum varchar2(100));

insert into t_rk_4 values (2,1,'1');
insert into t_rk_4 values (3,1,'1');
insert into t_rk_4 values (6,2,'1.2');
insert into t_rk_4 values (7,6,'1.2.6');
insert into t_rk_4 values (4,3,'1.3');
insert into t_rk_4 values (5,4,'1.3.4');
insert into t_rk_4 values (7,5,'1.3.4.5');
insert into t_rk_4 values (8,7,'1.2.6.7');
insert into t_rk_4 values (4,9,'1.9');
insert into t_rk_4 values (9,1,'1');

In the above date, child 8's parent is 7 only in case if tree context 1.2.6.7

select child_id,parent_id connect_by_isleaf,level,lpad(' ',level*3)||a.child_id
from t_rk_4 a
start with child_id = 8 connect by child_id = prior parent_id ORDER SIBLINGS BY child_id;

when I run the above query I am getting all tree contexts,

Is there a way I can only get tree positins thru 1.2.6.7 ?

In real table I have more than 1 million records..

Any help would be helpful..

Thanks
ay.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2009
Added on Jan 14 2009
6 comments
2,364 views