I'm not sure I understand the query in the first place.
I don't seem to see where you navigate up the tree.
In DB2 recursion must use UNION ALL. I don't think you can recurse using
the recursive common table expression twice.
Here is how I would write it:
WITH MaryAncestor(anc,desc) AS
( (SELECT parent as anc, child as desc
FROM ParentOf WHERE desc = "Mary")
UNION ALL
(SELECT P.anc, A.desc
FROM MaryAncestor A, ParentOf P WHERE A.anc = P.desc) )
SELECT anc FROM MaryAncestor
(something like that at least...)
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Received on Wed Feb 25 2004 - 04:06:11 CET