NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
R-24
Considerations—ROLLBACK WORK
the nonaudited objects by using CLOSE cursor and UNLOCK TABLE or FREE
RESOURCES.
ConsiderationsROLLBACK WORK
TMF transactions begin with BEGIN WORK and end with COMMIT WORK or
ROLLBACK WORK. See TMF Transactions on page T-5 or BEGIN WORK
Statement on page B-2 for more information.
ROLLBACK WORK returns status information to the SQLCA, so you can use
WHENEVER for processing related errors.
ROLLBACK WORK is equivalent to:
FREE RESOURCES (an SQL statement)
ABORTTRANSACTION (a procedure call)
Examples—ROLLBACK WORK
The following example uses ROLLBACK WORK to terminate a transaction without
committing database changes.
The user adds an order for two parts numbered 4130 to the ORDERS and ODETAIL
tables, but discovers that there is no such part number while updating the INVENT
table to decrement the quantity available.
>> BEGIN WORK;
>> INSERT INTO ORDERS VALUES ( 124, 860323, 860330, 75,
7654);
--- 1 row(s) inserted.
>> INSERT INTO ODETAIL VALUES (124, 4130, 250, 2);
---1 row(s) inserted.
>> UPDATE INVENT.PARTLOC SET QTY_ON_HAND = QTY_ON_HAND - 2
+> WHERE PARTNUM = 4130 AND LOC_CODE = "K43";
--- 0 row(s) updated.
>> ROLLBACK WORK;
ROLLBACK WORK cancels the inserts that occurred during the transaction and
releases the locks held on ORDERS and ODETAIL.