SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-172
ROLLBACK WORK Statement
ROLLBACK WORK Statement
Considerations for ROLLBACK WORK
MXCI Examples of ROLLBACK WORK
C Examples of ROLLBACK WORK
COBOL Examples of ROLLBACK WORK
The ROLLBACK WORK statement undoes all database modifications to audited
objects made during the current transaction, releases all locks on audited objects held
by the transaction, and ends the transaction. See Transaction Management on
page 1-12.
WORK is an optional keyword that has no effect.
ROLLBACK WORK has no effect if there is no active transaction.
ROLLBACK WORK closes all open cursors in the application, because cursors do not
span transaction boundaries. You cannot fetch with a cursor after a transaction ends
without reopening it.
Considerations for ROLLBACK WORK
Begin and End a Transaction
BEGIN WORK starts a transaction. COMMIT WORK or ROLLBACK WORK ends a
transaction.
MXCI Examples of ROLLBACK WORK
Suppose that you add an order for two parts numbered 4130 to the ORDERS and
ODETAIL tables. When you update the PARTLOC table to decrement the quantity
available, you discover there is no such part number in the given location.
Use ROLLBACK WORK to terminate the transaction without committing the
database changes:
BEGIN WORK;
INSERT INTO sales.orders
VALUES (124, DATE '1996-04-10',
DATE '1996-06-10', 75, 7654);
INSERT INTO sales.odetail
VALUES (124, 4130, 25000, 2);
UPDATE invent.partloc
SET qty_on_hand = qty_on_hand - 2
WHERE partnum = 4130 AND loc_code = 'K43';
ROLLBACK [WORK]
Embed