Page 1 of 1

cobol db2 program doubts

PostPosted: Thu Apr 29, 2010 12:42 am
by lakshmi narayanan
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.

Re: cobol db2 program doubts

PostPosted: Thu Apr 29, 2010 1:24 am
by dick scherrer
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.

Re: cobol db2 program doubts

PostPosted: Thu Apr 29, 2010 1:36 am
by lakshmi narayanan
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.

Re: cobol db2 program doubts

PostPosted: Thu Apr 29, 2010 3:46 am
by dick scherrer
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?