|
RPG does allow recursion via subprocedures. Perhaps you could write a stored procedure in RPG that could return the desired result sets? Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com "Smith, Dave" <DSmith@xxxxxxxxx> Sent by: midrange-l-bounces@xxxxxxxxxxxx 03/30/2005 09:47 AM Please respond to Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx> To <midrange-l@xxxxxxxxxxxx> cc Subject Recursion and SQL I am looking for a good example of breaking down a table that forms a parent child relationship of unknown levels (Tree structure). PARENT CHILD A A B A C A D B E B F E G E J G K H L I saw some good examples of recursive SQL on the web but apparently that's not allowed on the iSeries V5R2. I believe in won't be allowed under V5R3 but I can not find where I read that. I get the following message when trying a recursive SQL statement: Message: [SQL0346] Recursion not allowed for common table expressions. This is the result I'm looking for: LEVEL PARENT CHILD 1 A B 2 B E 3 E G 4 G K 3 E J 2 B F 1 A C 1 A D 1 H L I can then easily show this as: LEVEL 1 2 3 4 A B B E E G G K E J B F A C A D H L I want to do this for a warehousing application to show who feeds who. I was able to union a bunch of SQL statements together to achieve the desired results but it's ugly and does not account for unlimited levels. I can do it using RPG or using a combination of RPG and embedded SQL. Is there a simple SQL only solution that I'm missing? David Smith IT Consultant -- This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.