Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Connect by dumps
Ray <rbujarski_at_hotmail.com> wrote:
> I have a hierarchical relationship that I want to dump the entire
> family given a parent. I have a table that tracks parents and
> children relationships, I want to create a view that dumps the entire
> family given a parent.
> Scenario:
> p1 has child p2, p2 has child p3.
> Given p1, result set from view should be p2 and p3, given p2 result
> set from view should be p3 etc...
> Here is my pl/sql that creates the view:
> create view treepath
> as
> SELECT parent, child
> FROM td_view_dependants
> START WITH parent in (select parent from td_view_dependants)
> CONNECT BY child = prior parent
> However the results from this are p1 has p2 and p2, p2 has p3.
If you want start with p1 just write:
START WITH parent = 'p1'
If you want to go down the tree:
CONNECT BY PRIOR child = parent
greetings,
LW
Received on Thu Nov 13 2003 - 07:22:18 CST