SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
R-22
Considerations—ROLLBACK WORK
Considerations—ROLLBACK WORK
TMF transactions begin with BEGIN WORK and end with COMMIT WORK or
ROLLBACK WORK. For more information, see TMF Transactions on page T-6 or
BEGIN WORK Statement on page B-3.
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)
Example—ROLLBACK WORK
This 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.