- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Purpose and usage of SAVEPOINT in COBOL-DB2 program
Problem: How to use SAVEPOINT in a DB2? What is the purpose of SAVE-POINT in DB2? Explain with the help of an example.
The SAVEPOINT is used as a marker or tag to save the changes without committing in the database. After making the changes in the database, we can give a named SAVEPOINT statement and after that at any point of time we can rollback the changes to this savepoint using ROLLBACK statement.
Practically, we can have multiple SAVEPOINTS in our COBOL-DB2 program and we can jump back to any of these SAVEPOINTS using ROLLBACK. This will revert all changes made in the database post SAVEPOINT.
We can use ROLLBACK and SAVEPOINT as below.
SAVEPOINT MARK1 … …… ROLLBACK TO SAVEPOINT MARK1
For example, consider the below flow chart.
In the initial SQL statement, the ORDER_TOTAL is updated to the value 2346 using SQL statement and the current state of database is marked as ‘A’ using SAVEPOINT.
Further updation is done on the ORDER_TOTAL column and SAVEPOINT is again used to mark database state as ‘B’. Now if “ROLLBACK TO SAVEPOINT A” is given then the current state of database is restored to the point where ORDER_TOTAL = 2346.
- Related Articles
- What is the usage and purpose of DCLGEN and host variables used in COBOL-DB2 program
- What is the purpose and usage of “WHERE CURRENT OF” clause in a COBOL-DB2 program?
- What is the purpose and usage of “FOR UPDATE OF” clause in a COBOL-DB2 program
- What is the purpose and usage of SQLCODE within the SQLCA in a COBOL-DB2 program
- Purpose and usage of ROW-ID and SEQUENCE in a DB2
- How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?
- Steps involved in compilation of a COBOL-DB2 program
- Implementation of restart logic in a COBOL-DB2 program
- How to precompile a COBOL-DB2 program?
- Impact of database downtime on the COBOL-DB2 program
- Example and usage of JOINS in DB2
- How can you revert all the DB2 table changes done in a COBOL-DB2 program?
- Implementation of a table level locks in a COBOL-DB2 program during program execution
- How to execute a COBOL-DB2 program PROGA of plan PLANA?
- How LOST UPDATE and DIRTY READ impact the processing of a COBOL-DB2 program?