MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

looping query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nagasadhu
Beginner


Joined: 08 Jul 2006
Posts: 17
Topics: 6

PostPosted: Mon Feb 12, 2007 12:36 pm    Post subject: looping query Reply with quote

Hi

I have a customer table with

Code:
---------------------------------------
Acc_No.     Customer_id     Priority
----------------------------------------
(char10)    decimal(9,0)     char(1)
----------------------------------------
  111            1              1
  222            2              1
  222            3              2
  333            3              1
  333            4              2
  444            2              1
  444            4              2
  555            4              1
  555            5              2

I pass the customer_id to the query. I need the complete list of Customer_id that are related with the id passed directly or indirectly. Only 1& 2 priorities are possible.

For Customer_id
Input - 1
Output : 1

Input - 2
Output - 2,3,4,5

Input - 5
Output -5,4,3,2

Thanks for your time & effort
Regards
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Feb 12, 2007 9:20 pm    Post subject: Reply with quote

nagasadhu,

You need recursive Sql to get the desired results. Only DB2 Version 8 supports recursive sql.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group