Db2 Question

pts.
Tags:
DataCenter
Hi, I have a Cobol program updating 2 DB2 tables. The program reads a flat file and if the record read happens to be valid updates table A and if there is any error , then updates table B. After 'N' number of records are read from the flat file, the program will abend automatically. In that case, I need all records that have been updated in table A to be deleted and retain all the error records in table B as it is. These records from the flat file are appended to the table on a daily basis and hence when the program abends only the records updated to Table A for any particular day should be deleted and not all the records from table A. How should this be done?

Answer Wiki

Thanks. We'll let you know when a new response is added.

This can help you. I assume you are runnig a batch program. When you send your first SQL instruction DB2 starts a LUW than only ends with a COMMIT, ROLLBACK, END OF PROGRAM or ABEND. If the program abens automatically you must have an USER EXIT ROUTINE that will execute a new program which will delete the rows updated in table A based on this predicate DELETE FROM TABLE A WHERE <date-column> = <your criteria>.

To keep the rows inserted in table B you must send a COMMIT after each one of the inserts in order to start a new LUW, this is the only way to keep the information in other case if the program abends all tre rows will be ROLLBACKed. Please note that sending a COMMIT additionally will UPDATE te rows inserted in table A.

If you can provide me more information (like the ABEND condition) I can give you a more accurate solution.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following