How to rollback the updates in COBOL program?

All sort of Mainframes Interview Questions.
Post Reply
pra_passion
New Member
Posts: 7
Joined: Mon Feb 22, 2016 5:53 pm

How to rollback the updates in COBOL program?

Post by pra_passion »

Can anyone help me with the exact answer for below question.

Q). I have a COBOL DB2 program which is having a logic of updating the policy details in the table, unfortunately the program got abended due to other some other issues.. now I need to rollback the updates to the original status as it was. What are steps to rollback the update...where we need to give rollback statements in the program ?
User avatar
zum13
Registered Member
Posts: 89
Joined: Thu May 04, 2023 12:58 am

Re: How to rollback the updates in COBOL program?

Post by zum13 »

When a DB2 program abends, the current unit of work is automatically rolled back by default (there may be a way to override this, but I've not come across it). Some of the more severe SQLCodes can also cause an automatic rollback of changes.

If, however, your program has detected some sort of error and needs to exit under program control, then you would explicitly use the "ROLLBACK" statement to back out any changes back to the last commit. No other action would be necessary.

When you are in the situation where your program is periodically committing, then there is no way to roll back anything that has happened before the last commit unless you have a record of the old data that was on the table(s) before the program started running. If you had that data, it would be a matter of adding coding to the program to restore the original data.

Should you not have the original data, then you are into restoring from backup territory. That would be a matter of restoring the table using a full table backup and playing back the updates from the log archives to get back to the point before your update program run. This is a job that most likely would be handled by your database adminstrator. The downside to doing this is that depending upon how the tables you are updating are used, you may remove more than the just the updates your program made.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”