Specifying SET TRANSACTION Behavior
Go Up to Starting a Named Transaction
Use SET TRANSACTION
to start a named transaction, and optionally specify its behavior. The syntax for starting a named transaction using default behavior is:
SET TRANSACTION NAME name;
For a summary of the default behavior for a transaction started without specifying behavior parameters, see the page Starting With SET TRANSACTION. The following statements are equivalent: they both start the transaction named t1
, using default transaction behavior.
EXEC SQL SET TRANSACTION NAME t1; EXEC SQL SET TRANSACTION NAME t1 READ WRITE WAIT ISOLATION LEVEL SNAPSHOT;
The following table lists the optional SET TRANSACTION
parameters for specifying the behavior of the default transaction:
Parameter | Setting | Purpose |
---|---|---|
Access Mode |
|
Describes the type of access this transaction is permitted for a table. For more information about access mode, see Access Mode. |
Lock Resolution |
|
Specifies what happens when this transaction encounters a locked row during an update or a delete operation. It either waits for the lock to be released so it can attempt to complete its actions, or it returns an immediate lock conflict error message. For more information about lock resolution, see Lock Resolution. |
Isolation Level |
|
Determines the interaction of this transaction with other simultaneous transactions attempting to access the same tables.
|
Table |
|
Specifies a subset of available tables to lock immediately for this transaction to access. |
Database |
|
Specifies a subset of available databases that this transaction can access; it cannot access any other databases. The purpose of this option is to reduce the amount of system resources used by this transaction. Note: |
The complete syntax of SET TRANSACTION
is:
EXEC SQL SET TRANSACTION [NAME name] [READ WRITE| READ ONLY] [WAIT | NO WAIT] [[ISOLATION LEVEL] {SNAPSHOT [TABLE STABILITY] | READ COMMITTED [[NO] RECORD_VERSION]}] [RESERVING <reserving_clause> | USING dbhandle [, dbhandle ...]]; <reserving_clause> = table [, table ...] [FOR [SHARED | PROTECTED] {READ | WRITE}] [, <reserving_clause>]
Transaction options are fully described in the following sections.