Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi ! In a COBOL/DB2 program the

Status
Not open for further replies.

Idiot

Programmer
Oct 8, 2000
26
US
Hi !

In a COBOL/DB2 program the DB2 data base changes can be controlled by ROLL BACK or COMMIT statements.i.e if we modify the table in the program and at the end of the program if we want to revert back the changes we can control that through ROLL BACK statement.

Suppose the program also writes/REWRITES a sequential file.Is there any why to revert back the WRITE/REWRITE at the end of the program basing on some error condition?

Any help...


Thanks
 
I don't think so. The best thing is - if the amount the of records is not too large - to keep the records in storage until you are sure you want to write them. It is also possible to write those records to a temporary file and only after a commit you read them into the final output file. An other way is to give the records some kind of prefix and a later record with a conclusion with a lower prefix. After sorting you have a header record for each group on which you can decide what to do.
 
I would make a copy of the file with the JCL before you start and then access the copy from the program. The program can then set the return code if the file needs to be rolled back. The JCL can test the return code and decide whether to copy the updated file back over the original file.

Betty Scherber
Brainbench MVP for COBOL II
 
I think you don't want to restore the complete file when you want to use COMMITs. You do a COMMIT on a logical unit of work. Restore a complete file means that the logical unit of work is the complete file.

In that case Betty has a good solution.

If the logical unit of work is a smaller group of records, instead of using rewrite, you store the records until you are on the COMMIT point.

Changing your input is difficult at debugging time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top