Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Hierarchical Query
Fei Sha wrote:
>
> Hi, everybody,
>
> I want to do something with hierarchical query, but I don't know
> how to. And I wonder whether it is possible after all.
>
> Here is a table:
>
> TABLE T
> --------------------------------
> parent_id name child_id
> --------------------------------
> 1 A 2
> 2 B 3
> 3 C 4
> 4 D 5
> ...
> --------------------------------
>
> I want a query to return the trace of the hierarchy.
>
> i.e. A.B.C.D
Why don't you try PL/SQL ?
Something like
set serveroutput on
declare
result_string varchar2(200) := '';
cursor C is SELECT name
FROM t START WITH parent_id = 1 CONNECT BY prior child_id = parent_id;begin
You may have problems with dbms_output.put_line, the argument of which
is limited in length to 250 characters or so. You could write this as a
PL/SQL function as well.
--
Regards,
Stéphane Faroult
Oriole Corporation
Received on Sat Jan 23 1999 - 16:25:00 CST