IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

ROLLBACK for previous table updates


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ssowmya

New User


Joined: 10 Oct 2006
Posts: 40

PostPosted: Tue Apr 24, 2007 9:56 am
Reply with quote

Hi

We need to code a program that will be updating/inerting/deleting into tables T1,T2,T3,T4 and T5. When there is failure in one of the operations, all the previous updates need to be rolled back.

For example, consider the below scenario

New row is inserted into table T1 which is succesfull
A row is deleted from table T2 which is succesfull
When I try to insert record into table T3, I get an error.

In the above scenario, the updates to T1 and T2 need to be backed out. Could anyone please let me know if there is a simple solution to this problem.

Thanks
Sowmya
Back to top
View user's profile Send private message
ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Tue Apr 24, 2007 12:10 pm
Reply with quote

Hi,

Its simple use a flag as WI-Rollback, and set this flag if any one of the T1,T2 or T3 sqlcode not equal to zero.

And after the three table processing check as

If WI-Rollback

Rollback db2 command


Cheers
Ashwin
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 12:21 pm
Reply with quote

Do you understand the concept of LUW? All inter-related operations are considered to a Logical Unit of Work. Once all parts of the LUW are successfully completed, commit the LUW to make the updates permanent. If there is a failure of any of the parts of the LUW, issue a rollback and all the other parts of the LUW will be reversed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top