Technical data

ROLLBACK
9. If a database exception condition occurs during the execution of a ROLLBACK
statement, the DBCS places a database exception condition code in the special
register DB-CONDITION. This code identifies the condition.
Additional References
Section 2.2, on reserved words (database special registers)
HP COBOL Reference Manual, Chapter 6, section on scope of statements
Section 4.8.1, on database On Error condition
USE statement (USE FOR DB-EXCEPTION)
Section 5.2.4, on subschema description (DB)
Example
This ROLLBACK example illustrates one way to end a database transaction and
undo the changes made to the database during the transaction.
010-BEGIN-UPDATE-TRANSACTION.
* This transaction begins with the first READY statement in
* the run unit, continues through a series of DML database
* access statements, and ends with a COMMIT or ROLLBACK.
.
.
.
100-END-UPDATE-TRANSACTION.
DISPLAY "DO YOU WANT TO COMMIT THIS TRANSACTION ? ".
ACCEPT ANSWER.
IF ANSWER = "YES"
COMMIT . . .
ELSE
ROLLBACK
ON ERROR
IF DB-CONDITION = DBM-NOT-BOUND
DISPLAY " Database not bound"
ELSE
CALL "DBM$SIGNAL".
END-IF
END-ROLLBACK.
4–58 Procedure Division