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!

Binary Tree Query using PL/SQL

Aviral_14Dec 3 2019 — edited Dec 3 2019

I have a below table and i want the output in the form of a tree such that if we pass the Unique_Id of Admin we will be able to view all the list as all are the child of ADMIN.

Similarly if i pass the unique_id of user1Child1 i will get user1Child1child1 and user1Child1child2 , because user1Child1 is the parent of both of them.

similar case if user1Child1child1 and user1Child1child2 have children's  they should also come in the list and so on...

Table:

     

NameSponser_IDAdded_ByPositionUnique_ID
ADMINEFQAAAA123ADMINNULLEFQAAAA123
user1Child1EFQAAAA123ADMINLeftEFQAAAA456
user2Child2EFQAAAA123ADMINRightEFQAAAA789
user1Child1child1EFQAAAA456ADMINRightEFQAAAD085
user1Child1child2EFQAAAA456ADMINLeftEFQAAAE985
user2Child2child1EFQAAAA789ADMINleftEFQAAAP210
Comments
Post Details
Added on Dec 3 2019
1 comment
1,146 views