After a program has completed its database access activities successfully, it must issue the FINISH function to "close" the database and commit any changes that it has made. The following example shows how to code the FINISH DML statement in COBOL:
FINISH. PERFORM IDMS-STATUS.
It is also possible to commit changes without terminating the run unit. This is often done at the completion of a logical unit of work to free up records that have been updated so that other programs can access them, while keeping the run unit open so that more work can be done. To do this, a COMMIT DML statement is used instead of a FINISH, as shown in the following example that commits changes but maintains the run unit's currencies:
COMMIT. PERFORM IDMS-STATUS.
An option on the COMMIT statement nullifies currencies in addition to committing database changes.
If an error is encountered during program execution that prevents successful completion of the logical unit of work, the program should issue a ROLLBACK DML statement instead of a FINISH as shown in the following example in which database changes are rolled back and the run unit terminated:
ROLLBACK. PERFORM IDMS-STATUS.
An option on the ROLLBACK statement permits the run unit to continue after the database changes have been rolled back.
Note: Database changes are only rolled back automatically when the run unit is executing under central version. In local mode, the database must be manually recovered.
For more information on the use of these statements and their impact on throughput and database integrity, see Run Units, Locks, and Database Transactions.
Copyright © 2013 CA.
All rights reserved.
|
|