Chapter 9 SQL Statements
407
BEGIN TRANSACTION statement
Use this statement to begin a user-defined transaction.
BEGIN TRAN[SACTION] [
transaction-name
]
None.
None.
"COMMIT statement" on page 420
"ISOLATION_LEVEL option" on page 194
"ROLLBACK statement" on page 597
"SAVEPOINT statement" on page 600
The optional parameter transaction-name is the name assigned to this
transaction. It must be a valid identifier. Use transaction names only on the
outermost pair of nested BEGIN/COMMIT or BEGIN/ROLLBACK
statements.
When executed inside a transaction, the BEGIN TRANSACTION statement
increases the nesting level of transactions by one. The nesting level is
decreased by a COMMIT statement. When transactions are nested, only the
outermost COMMIT makes the changes to the database permanent.
Both Adaptive Server Enterprise and Adaptive Server Anywhere have two
transaction modes.
The default Adaptive Server Enterprise transaction mode, called unchained
mode, commits each statement individually, unless an explicit BEGIN
TRANSACTION statement is executed to start a transaction. In contrast, the
ISO SQL/92 compatible chained mode only commits a transaction when an
explicit COMMIT is executed or when a statement that carries out an
autocommit (such as data definition statements ) is executed.
You can control the mode by setting the CHAINED database option. The
default setting for ODBC and embedded SQL connections in Adaptive
Server Anywhere is ON, in which case Adaptive Server Anywhere runs in
chained mode. (ODBC users should also check the AutoCommit ODBC
setting). The default for TDS connections is OFF.
In unchained mode, a transaction is implicitly started before any data
retrieval or modification statement. These statements include: DELETE,
INSERT, OPEN, FETCH, SELECT, and UPDATE. You must still explicitly
end the transaction with a COMMIT or ROLLBACK statement.
You cannot alter the CHAINED option within a transaction.
Function
Syntax
Permissions
Side effects
See also
Description