Technical data

Figure 6–1 Using the COMMIT Statement
Program Statement
READY
.
.
.
COMMIT
.
.
.
READY
.
.
.
COMMIT
.
.
.
ZK−6065−GE
Groups of Interdependent Records
RECORD 4 (adds a credit amount to RECORD 5)
RECORD 5 (updates data in RECORD 6)
RECORD 6
RECORD 7 (summarizes data changes for the group)
RECORD 1 (transfers data to RECORD 2)
RECORD 2 (transfers data to RECORD 1)
RECORD 3 (summarizes data changes for the group)
The ROLLBACK statement cancels all changes made to the database since the
last executed READY statement and returns the database to its condition at the
last quiet point. The DBCS performs an automatic ROLLBACK if your run unit
ends without executing a COMMIT or if it ends abnormally.
In Example 6–1 an order-processing application totals all items ordered by a
customer. If the order amount exceeds the credit limit, the program executes a
ROLLBACK and cancels the transaction updates. Notice that the credit limit is
tested for each ordered item, thus avoiding printing of an entire invoice prior to
cancelling the order.
6–4 DML Programming—Tips and Techniques