COMMIT

From InterBase
Jump to: navigation, search

Go Up to Statement and Function Reference (Language Reference Guide)


Makes changes of a transaction to the database permanent, and ends the transaction. Available in gpre, DSQL, and isql.

 COMMIT [WORK] [TRANSACTION <name>] [RELEASE] [RETAIN [SNAPSHOT]];
Important: In SQL statements passed to DSQL, omit the terminating semicolon. In embedded applications written in C and C++, and in isql, the semicolon is a terminating symbol for the statement, so it must be included.
Argument Description

WORK

An optional word used for compatibility with other relational databases that require it

TRANSACTION <name>

Commits transaction name to database. Without this option, COMMIT affects the default transaction.

RELEASE

Available for compatibility with earlier versions of InterBase.

RETAIN [SNAPSHOT]

Commits changes and retains current transaction context.

Description: COMMIT is used to end a transaction and:

  • Write all updates to the database.
  • Make the changes of transaction visible to subsequent SNAPSHOT transactions or READ COMMITTED transactions.
  • Close open cursors, unless the RETAIN argument is used.

A transaction ending with COMMIT is considered a successful termination. Always use COMMIT or ROLLBACK to end the default transaction.

Tip: After read-only transactions, which make no database changes, use ­COMMIT rather than ROLLBACK. The effect is the same, but the performance of subsequent transactions is better and the system resources used by them are reduced.
Important: The RELEASE argument is only available for compatibility with previous versions of InterBase. To detach from a database use DISCONNECT.

Examples: The following isql statement makes permanent the changes to the database made by the default transaction:

COMMIT;

The next embedded SQL statement commits a named transaction:

EXEC SQL
COMMIT TR1;

The following embedded SQL statement uses COMMIT RETAIN to commit changes while maintaining the current transaction context:

EXEC SQL
COMMIT RETAIN;

See Also