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 

DB2 program logic needed

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


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Fri Mar 02, 2007 10:18 am    Post subject: DB2 program logic needed Reply with quote

I have a file with some records and the fields are :
Code:

EMPNO   EMPNAME CLASS
1   ABC   A
2   DEF   A
3   PQR   A
.
.

I have to write a logic which will read each EMPNO from the file and has to query a DB2 table in which for a CLASS A there are always two marks associated as below:
Code:

CLASS   MARKS
A   1
A   2

I want to form a output file which should have as below:
Code:

EMPNO   EMPNAME CLASS   MARKS
1   ABC   A   1
1   ABC   A   2
2   DEF   A   1
2   DEF   A   2
3   PQR   A   1
3   PQR   A   2
.
.

If the input number of records are X then the output records should be 2X.
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: Fri Mar 02, 2007 10:29 am    Post subject: Reply with quote

yadav2005,

Code:

1. open file
2. read file
3. open cursor
4. fetch cursor until end of cursor
5. for every fetch move the values to output file
6. write output
7. close cursor
8. Repeat step 2 thru 7 until end of file
9. close file


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