cobol db2 program doubts



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

cobol db2 program doubts

Postby lakshmi narayanan » Thu Apr 29, 2010 12:42 am

Hi,

I have a cobol Db2 program.I have an input file which contains a record "GOLD".The file is read and this value is passed as input to SQL cursor .The records are fetched and written to a output file.My requirement is that i have another record(second) as "SILVER".So,i need to pass this input into SQL query and generate the output in the same file followed by output of first record.I tried with perform 1000-cursor thru 1000-exit until end-of-input-file and it does not work.I have even tried with cobol tables(internal) .I am not sure of the syntax.Please advise how this requirement can be achieved.
lakshmi narayanan
 
Posts: 4
Joined: Thu Apr 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: cobol db2 program doubts

 

Re: cobol db2 program doubts

Postby dick scherrer » Thu Apr 29, 2010 1:24 am

Hello and welcome to the forum,

First - make sure you use proper/consistent terms. Database tables do not have records - they have rows.

and it does not work.
Basically gives no information that can be used to help you. . . What does "didn't work" mean? Did it not compile? Was there an abend? Was the wrong output written? Was no output written?

To do what you want you need to read the GOLD record, open the cursor and fetch all of the GOLD rows, and write them to the output, and close the cursor . Then read the SILVER record, and repeat the process. The cursor open and processing would be code that is performed for each record in the original input file. The external files should be opened at the beginning of the program and closed after all processing is done.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: cobol db2 program doubts

Postby lakshmi narayanan » Thu Apr 29, 2010 1:36 am

Dick,I was getting SOC4 abend.I agree to your suggestion.Can i do it with perform statement?.
Suppose,I have a statement like perform 1000-cursor thru 1000-exit until eof-input.where EOF-input refers to the end-of input file.Does that work?.

The 1000-cursor contains open fetcch and close cursor statements.
lakshmi narayanan
 
Posts: 4
Joined: Thu Apr 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: cobol db2 program doubts

Postby dick scherrer » Thu Apr 29, 2010 3:46 am

Hello,

Does that work?.
Done correctly, that should work.

Can i do it with perform statement?.
If i understand, i believe this should be done with at least one perform statement.

What was the last thing the program did before the s0c4? What causes the s0c4? Does your program call any others? His this code ever worked or is this a new program or new code added to an existing program?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post