ROLLBACK
Go Up to Statement and Function Reference (Language Reference Guide)
Restores the database to its state prior to the start of the current transaction or savepoint. Available in gpre
, DSQL, and isql
.
ROLLBACK [TRANSACTION name] [TO SAVEPOINT <name>][WORK][RELEASE];
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 |
---|---|
|
Specifies the transaction to roll back in a multiple-transaction application. [Default: roll back the default transaction]. |
|
Specifies the savepoint to roll back to. |
|
Optional word allowed for compatibility. |
|
Detaches from all databases after ending the current transaction; SQL only. |
Description: ROLLBACK
undoes changes made to a database by the current transaction, then ends the transaction. It breaks the program connection to the database and frees system resources. Use RELEASE
in the last ROLLBACK
to close all open databases. Wait until a program no longer needs the database to release system resources.
The TRANSACTION
clause can be used in multiple-transaction SQL applications to specify which transaction to roll back. If omitted, the default transaction is rolled back. The TRANSACTION
clause is not available in DSQL.
RELEASE, available only in SQL, detaches from all databases after ending the current transaction. In effect, this option ends database processing. RELEASE is supported for backward compatibility with older versions of InterBase. The preferred method of detaching is with DISCONNECT.
Examples: The following isql
statement rolls back the default transaction:
ROLLBACK;
The next embedded SQL statement rolls back a named transaction:
EXEC SQL
ROLLBACK TRANSACTION MYTRANS;