COMMIT WORK statement

Use the COMMIT WORK statement to commit all modifications made to the database from the beginning of a transaction.

Syntax

COMMIT [ WORK ]

Usage

The COMMIT WORK statement informs the database server that you reached the end of a series of statements that must succeed as a single unit. The database server takes the required steps to make sure that all modifications that the transaction makes are completed correctly and saved to disk.

Use COMMIT WORK only at the end of a multistatement operation in a database with transaction logging, when you are sure that you want to keep all changes made to the database from the beginning of a transaction.

The COMMIT WORK statement releases all row and table locks.

The WORK keyword is optional in a COMMIT WORK statement. The following two statements are equivalent:
COMMIT;
COMMIT WORK;
The following example shows a transaction bounded by BEGIN WORK and COMMIT WORK statements.
BEGIN WORK;
   DELETE FROM call_type WHERE call_code = 'O';
   INSERT INTO call_type VALUES ('S', 'order status');
COMMIT WORK;

In this example, the user first deletes the row from the call_type table where the value of the call_code column is O. The user then inserts a new row in the call_type table where the value of the call_code column is S. The database server guarantees that both operations succeed or else neither succeeds.

In Informix® ESQL/C, the COMMIT WORK statement closes all open cursors except those that were declared using the WITH HOLD option.