Professional Documents
Culture Documents
COMMIT is the DB2 statement which saves the updates made to DB2 tables since the start of the
program or the last COMMIT.
It does so by physically applying the all the changes to the DB2 Log.
When a program abends, the changes are rolled back to the last Commit / Sync point.
A unit of work is a portion of processing that gives a logical completion and helps in achieving data
integrity. The Updates done during a unit of work are saved by issuing a DB2 COMMIT.
For Example, suppose we have an application that involved update of 2 tables which are related to
each other. And suppose the update of table1 is COMMITed and the program abends before
COMMITing the UPDATE to the other. The data in the 2 tables will no longer be synchronous. To
Achieve data integrity, we must issue a COMMIT only when the processing reaches a logical end.
Checkpoint-Restart Logic:
Application Programs which process large volumes of data and those that involve modification of Db2
Tables need to incorporate a Restart Logic when a system error occurs.
This is to help in continuing the processing from the record next to the last successfully processed
row.
Pgm_name
Job_name
Commit_Frequency
No_of_Commits
Checkpoint_Key
Checkpoint_Time
Declare 2 cursors – both with ORDER BY for the columns that form the unique index for the
table. One cursor will be used to do normal processing. The other cursor while restarting
the application is used to reposition at the record following the last saved record . This is
done using additional predicates like Where Key > Last_Key
For every row that is fetched, processing is done, tables are updated. Then based on
elapsed time since last commit or commit frequency, etc, COMMIT is issued
Before every COMMIT is issued, the ckpt_restart table is updated with the Current key for
If the program is restarted, it reads the key in the ckpt table and uses that in 2 nd cursor to
After the processing is complete for all the rows, the ckpt table keys are set to default
Values.
If File inputs are used for processing, then we need to reposition the input record by saving
the read_count in the ckpt table. And upon restart perform read in a loop till the count is >
Or else is the file is sorted on the same key that is stored in the ckpt table, we can
If there are File outputs, they need to be have a disp=Mod in the jcl to continue appending The
records.