Hierarchy Query Help

Database
N/A

Hierarchy Query Help

Hi ,
I have a source table with two columns and i need the result in a single column as follows :-

Source Table :-
OLDID NEWID
-------- --------
123 234
234 345
345 456
123 567
567 789
..... .....
..... .....
and so on

Expected Result:
--------------------
ResultColumn
123,234,345,456
234,345,456
345,456
123,567,789
567,789
......................
......................

For each record pick the NEWID and navigate whether any equivalent OLDID exists for that NEWID, if exists concat OLDID || ',' || NEWID and repeat until no OLDID exists for the NEWID.

Please advice,

Thanks in advance

1 REPLY

Re: Hierarchy Query Help

Hi Meem,

Do you know the maximum length of these chains? The reason I ask is that you basically need a select statement for each join and you also potentially have the problem of loops
eg.
OLDID NEWID
123 456
456 123