Re: recursive to tree conversion?
Posted in 1996
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Robert Donat <rdonat@sigg.com> wrote: >Has anyone written a procedure or ESQL program which converts a >recursive table (ie employee/supervisor) into a tree structure type >table (ie left/right [in/out], level)? Well, I'm sure someone has. The >question is does anyone know where I might look at such code? Platform >independent. Makes no difference to me. >Also, does Oracle work well with this type of tree structure with it's >"hierarchical queries?" >Thanks, >Rob. >-- >############################################# ># Rob Donat Signature Group # ># rdonat@sigg.com # ># http://sashimi.wwa.com/~donat # >############################################# You can try the following Oracle SQL statement : SELECT LEVEL, employee_no FROM employee_table WHERE your_condition CONNECT BY PRIOR employee_no = supervisor_no START WITH 1 The result will be LEVEL EMPLOYEE_NO SUPERVISOR_NO 1 0001 2 0002 0001 2 0003 0001 1 0004 2 0005 0004 2 0006 0004 ...