Neoview SQL Reference Manual (R2.4 SP2)
COMMIT WORK Statement
• “Considerations for COMMIT WORK”
• “Example of COMMIT WORK”
The COMMIT WORK statement commits any changes to objects made during the current
transaction, releases all locks on objects held by the transaction, and ends the transaction. See
“Transaction Management” (page 28).
COMMIT [WORK]
WORK is an optional keyword that has no effect.
COMMIT WORK issued outside of an active transaction generates error 8605.
Considerations for COMMIT WORK
BEGIN WORK starts a transaction. COMMIT WORK or ROLLBACK WORK ends a transaction.
Example of COMMIT WORK
Suppose that your application adds information to the inventory. You have received 24 terminals
from a new supplier and want to add the supplier and update the quantity on hand. The part
number for the terminals is 5100, and the supplier is assigned supplier number 17. The cost of
each terminal is $800.
The transaction must add the order for terminals to PARTSUPP, add the supplier to the SUPPLIER
table, and update QTY_ON_HAND in PARTLOC. After the INSERT and UPDATE statements
execute successfully, you commit the transaction, as shown:
-- This statement initiates a transaction.
BEGIN WORK;
--- SQL operation complete.
-- This statement inserts a new entry into PARTSUPP.
INSERT INTO invent.partsupp
VALUES (5100, 17, 800.00, 24);
--- 1 row(s) inserted.
-- This statement inserts a new entry into SUPPLIER.
INSERT INTO invent.supplier
VALUES (17, 'Super Peripherals','751 Sanborn Way',
'Santa Rosa', 'California', '95405');
--- 1 row(s) inserted.
-- This statement updates the quantity in PARTLOC.
UPDATE invent.partloc
SET qty_on_hand = qty_on_hand + 24
WHERE partnum = 5100 AND loc_code = 'G43';
--- 1 row(s) updated.
-- This statement ends a transaction.
COMMIT WORK;
--- SQL operation complete.
COMMIT WORK Statement 59