Commit Work Statement; Considerations For Commit Work; Begin And End A Transaction; Effect Of Constraints - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

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
COMMIT [WORK]
WORK is an optional keyword that has no effect.
COMMIT WORK has no effect outside of an active transaction.
Considerations for COMMIT WORK

Begin and End a Transaction

BEGIN WORK starts a transaction. COMMIT WORK or ROLLBACK WORK ends a transaction.

Effect of Constraints

When COMMIT WORK is executed, all active constraints are checked, and if any constraint is
not satisfied, changes made to the database by the current transaction are canceled—that is, work
done by the current transaction is rolled back. If all constraints are satisfied, all changes made
by the current transaction become permanent.
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.
56
SQL Statements
32).

Advertisement

Table of Contents
loading

Table of Contents