Rollback changes coming undone
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
SAVEPOINT POINTX ON ROLLBACK RETAIN CURSORS; ...Subsequent processing... ROLLBACK TO SAVEPOINT POINTX;
The ROLLBACK will cause any data or schema changes made in the "subsequent processing" to be undone. It is permissible to code multiple SAVEPOINTs within a UOW and you can ROLLBACK to any SAVEPOINT (as long as you do not reuse the SAVEPOINT name). The UNIQUE key word can be specified to ensure that the SAVEPOINT name is not reused within the unit of recovery.
There are two clauses that can be specified to further define the nature of the SAVEPOINT when a ROLLBACK is issued: RETAIN CURSORS -- specifies that any cursors that are opened after the SAVEPOINT is set are not tracked, and will not be closed when rolling back to that SAVEPOINT. You will want to use this. RETAIN LOCKS -- specifies that any locks that are acquired after the SAVEPOINT is set are not tracked, and will not be released when rolling back to the SAVEPOINT. Keep in mind though, that even if RETAIN CURSORS is specified some of the cursors may not be usable. For example, if the ROLLBACK removes a row (that is, rolls back an INSERT) on which the cursor was positioned, an error will arise.Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.
Dig Deeper on IBM DB2 management
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.
Meet all of our Data Management/Data Warehousing experts
View all Data Management/Data Warehousing questions and answers
Start the conversation
0 comments