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!

how to find out all child elements using query

vis1985Dec 23 2015 — edited Dec 24 2015

Hi All,

Need a help.

I have data like parent-child relationship( or binary tree) like below.

code 17942 is parent having child 1863,2173 and 5678.

Again 1863 have child 301,4,5.

HIERARCHY_STRUCURE column specipfies the how to reach the element from root and CHILD_IND gives you idea about the leaf node(TRUE - Leaf node ,false- then PARENT node).

CODEHIERARCHY_STRUCTURECHILD_IND
17942False
186317942False
217317942False
567817942True
1052173,17942True
3011863,17942True
41863,17942False
51863,17942True
14,1863,17942True
24,1863,17942True

I need to prepare SQL query where i need to find out all children elements for specified code.

i.e. if i passed codes to query from IN clause - 1863 and 5678 then expecting below 5 rows with CODE value

301,5,1,2,5678

(not 4 as its PARENT NODE).

Thanks in advance.

Rahul

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 21 2016
Added on Dec 23 2015
8 comments
3,322 views