Re: Recursive closure
Date: Sat, 21 Jul 2001 23:33:36 GMT
Message-ID: <9i27b5$t7k$1_at_stlnews.stl.ibm.com>
In IBM DB2, you would express it as:
with temp(level,name) as
(select number,name from tblName where PK=1
UNION ALL
select number,name from tblName T,temp P where T.PK=P.FK )
select * from temp
The above query might have an infinite recursion, you will have to limit that somehow in the where clause.
Relational algebra and closure...cant think of anything right now!
Thanks
Aakash
"Tim Galle" <38726_at_stud.ehsal.be> wrote in message
news:qXM07.16840$YS5.1992966_at_afrodite.telenet-ops.be...
> I have a table with a recursive relation. Something like:
> tblName(Number (PK), Name, SuperNumber (FK) )
>
> I would like to create a query who gives all the names at all the levels.
> (number differs from record to record) You can't do that in SQL2,
> but I heared it was possible in SQL3.
>
> How do you write this in relational algebra?
>
> Does someone know where I could find this information?
>
> tia
> Tim
>
>
>
Received on Sun Jul 22 2001 - 01:33:36 CEST