If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Recursive query - Help needed...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-08, 14:58
nnatraj nnatraj is offline
Registered User
 
Join Date: Mar 2008
Posts: 1
Recursive query - Help needed...

Hi,

We are using DB2 V7 (MVS) in our shop, which dont have the luxury of the 'WITH clause' - CTE support to accomplish recursive queries.

Here is my problem -
Table1
From-ID To-ID
A1 M1 - Member A1's id changes to M1
M1 D1 - M1 changes to D1
D1 A2 - D1 changes to A2
A2 A1 - A2 changes to A1
R1 R2 - R1 changes to R2
R3 R2 - R3 changes to R2

Above table structure, records a series of changes that a member ID undergoes.

My problem is, given the member ID A2, my query has to return all first 4 rows.

As I mentioned earlier, I understand that DB2 version 7 for MVS doesnt support the CTE construct to handle recursive queries - Version 8 and up does.

Pls suggest me a query to handle the above problem. Appreciate your support on this.

Regards
Reply With Quote
  #2 (permalink)  
Old 03-11-08, 15:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Either you do the recursion in your application, or - if you know the maximum recursion depth to be at a reasonable level - try several self-joins.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On