Re: Tree Walk statements

From: Kenny Gump <kgump_at_mylanlabs.com>
Date: Fri, 8 Jan 1999 07:19:11 -0500
Message-ID: <3695f7de.0_at_news.mountain.net>


I think what you are wanting is something like this:

select lpad(' ', 3*level-3) || ename, level, empno, mgr, deptno from emp
connect by prior empno = mgr
start with mgr is null;

This is assuming that the column mgr is a self-referencing foreign key which references the empno in the same table.

Kenny Gump
OCP 7.3 DBA



Justin Stopforth wrote in message <3695d40f.9180755_at_news.icon.co.za>...
>Hi
>
>I'm having trouble with a tree walk statement and if anyone could give
>me a hand I would appreciate it.
>
>Here's the deal:
>
>Table name: assignments
>Field1: employee (pk)
>Field2: manager (also an employee)
>Top level managers have themselves as managers
>
>I need a list (two columns) of each manager and ALL his subordinates
>E.g.
>A manages B who manages C. I need a list that looks like:
>A B
>A C
>B C
>
>Thanks
>
>Justin
Received on Fri Jan 08 1999 - 13:19:11 CET

Original text of this message