×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Hi All,

I am having a problem creating a recursive query. DB2 returns an invalid
reference error (SQL0346):
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.msg.doc/doc/sql0346.htm

Based on this error code, the problem seems to be a result of doing a
recursive query! ... Which is exactly what I need! According to IBM
documentation this syntax should work and preform a recursive style query:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0000879.htm

The error refers to where it says "FROM RPL" on line 4 ... (The part that
makes the query recursive)

WITH RPL (NODEID, PARENT, NAME) AS (
     SELECT ROOT.NODEID, ROOT.PARENT, ROOT.NAME FROM MNUNODES ROOT WHERE
NODEID = :NODEID
        UNION ALL
     SELECT CHILD.NODEID, CHILD.PARENT, CHILD.NAME FROM RPL, MNUNODES CHILD
     WHERE CHILD.PARENT=RPL.NODEID
)
SELECT DISTINCT NODEID, PARENT, NAME FROM RPL

One thing to note is that the data shall never have a structure that may
cause an infinite loop.

Does anyone have any suggestions?

Regards,
Milan Zdimal

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.