FirebirdSQL logo

What the Options Mean

DECLARE TRANSACTION…​ declares the described transaction, without activating it.SET TRANSACTION…​, on the other hand, activates the transaction, temporarily switching the SQL_ATTR_AUTOCOMMIT global attribute of the ODBC API to SQL_AUTOCOMMIT_OFF.The transaction will have to be finished explicitly;when it ends, the abiding rule of the API resumes.

LOCAL limits a transaction to acting only within the context of the current connection.

NAME transaction-name is a uniquely-named transaction, prepared for use by any connections in the global environment.

USING namedUniqueWorkspace is a uniquely-named transaction workspace in which NAME transaction-name can be set to run by any connections in the global environment.Identically named transactions with differing parameters can run in the same named workspace.

Named Transactions and Transaction Workspaces

The construct DECLARE TRANSACTION …​ NAME transaction-name [USING namedUniqueWorkspace] allows explicit transactions to be configured and saved into the global environment in preparation for repeated use for any connection request or by any active connection.An instance of the saved transaction can be called into action by a specific form of the SET TRANSACTION command:

For a connection request:

SET TRANSACTION NAME MyReadTransaction

or

SET TRANSACTION NAME MyReadTransaction USING MyDsnDb1

for separate requests within a single active connection:

SET TRANSACTION LOCAL NAME MyReadTransaction

or

SET TRANSACTION LOCAL NAME MyReadTransaction USING MyDsnDb1

and, in this connection, for another request:

SET TRANSACTION LOCAL NAME MyWriteTransaction

or

SET TRANSACTION LOCAL NAME MyWriteTransaction USING MyDsnDb1

The form SET TRANSACTION …​ NAME transaction-name [USING namedUniqueWorkspace] differs from earlier implementations whereby the configuration set by the SET command would be repeated for the next transaction.The inclusion of the NAME and/or USING clauses makes the configuration repeatable on demand by use of the name.

Important

A return to the usual mode of operation requires a detach/connect cycle.