The following code fragment shows how you might place statements within a transaction. The transaction is made up of the statements that occur between the BEGIN WORK and COMMIT WORK statements. The transaction locks the stock table (LOCK TABLE), updates rows in the stock table (UPDATE), deletes rows from the stock table (DELETE), and inserts a row into the manufact table (INSERT).
BEGIN WORK; LOCK TABLE stock; UPDATE stock SET unit_price = unit_price * 1.10 WHERE manu_code = 'KAR'; DELETE FROM stock WHERE description = 'baseball bat'; INSERT INTO manufact (manu_code, manu_name, lead_time) VALUES ('LYM', 'LYMAN', 14); COMMIT WORK;
The database server must perform this sequence of operations either completely or not at all. When you include all of these operations within a single transaction, the database server guarantees that all the statements are completely and perfectly committed to disk, or else the database is restored to the same state that it was in before the transaction began.
Related statements: COMMIT WORK and SAVE EXTERNAL DIRECTIVES
For discussions of transactions and locking, see the IBM Informix Guide to SQL: Tutorial.