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 

Reg: DB2 Query

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


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Sat May 28, 2005 4:08 am    Post subject: Reg: DB2 Query Reply with quote

Hi,

I have a requirement.
I have 2 tables. Detail table and Error Table.
Records are stored in Detail table as

Id - Detail Sequence - Packet Sequence

100 - 1 - 1
100 - 2 - 2
100 - 3 - 2
100 - 4 - 2
100 - 5 - 5
100 - 6 - 5
100 - 7 - 5
.
.
.
If any of the above records are in error, the Error table will contian

Id - Detail Seqence - Err-Code
100 - 2 - 4002
100 - 3 - 4002
100 - 3 - 4006
100 - 5 - 4007
.
.

My requirement here is, if I have a Id and Detail Sequence, I would like to know if any of the records corresponding to that Packet-Sequence are in Error.

For Eg. say I have Id as 100 and Detail-Sequence as 2. The Packet-Sequence is 2 for the record which has Detail-sequence as 2. The Packet-Sequence is also 2 for the records which has Detail-Sequence as 3 and 4. I would like to have a query which gives me the Id Err-Code from Error-table corresponding to that packet (i.e., For Detail Sequence numbers 2, 3, 4) joining Detail and Error table in a Single query.

Am I clear with the requirement? Please give me a solution.

Thanks & Regards,
Ravishankar
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Sun May 29, 2005 11:26 am    Post subject: Reply with quote

Ravishankar,

Unless I am missing something , it is very easy query(I did not test it)

Code:

SELECT *                                         
  FROM ERR_TABLE                                       
 WHERE (ID_NO,DTL_SEQ) IN (SELECT ID_NO         
                                 ,DTL_SEQ       
                             FROM DTL_TABLE)           
 ;                                               


Hope this helps...

Cheers

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