Contents IndexCOMMENT statement Compound statements

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 43. Watcom-SQL Statements
      COMMIT statement

Function

To make any changes to the database permanent.

Syntax

     COMMIT [ WORK ]

Usage

Anywhere.

Permissions

Must be connected to the database.

Side effects

Closes all cursors that were not opened with the WITH HOLD option.

See also

Description

The COMMIT statement ends a logical unit of work (transaction) and makes all changes made during this transaction permanent in the database. A transaction is defined as the database work done between successful COMMIT and ROLLBACK statements on a single database connection.

The COMMIT statement is also used as the second phase of a two-phase commit operation. See "Coordinating transactions with multiple database engines" and "PREPARE TO COMMIT statement" for more information.

The changes committed are those made by the data manipulation statements: INSERT, UPDATE, and DELETE, as well as the ISQL load statement INPUT.

The data definition statements all do an automatic commit. They are:

The COMMIT statement fails if SQL Anywhere detects any invalid foreign keys. This makes it impossible to end a transaction with any invalid foreign keys. Usually, foreign key integrity is checked on each data manipulation operation. However, if either the database option WAIT_FOR_COMMIT is set ON or a particular foreign key was defined with a CHECK ON COMMIT clause, the database engine will not check integrity until the COMMIT statement is executed. For a two-phase commit operation, these errors will be reported on the first phase (PREPARE TO COMMIT), not on the second phase (COMMIT).

Contents IndexCOMMENT statement Compound statements