Declaring Transaction Names
From InterBase
Go Up to Naming Transactions
Transaction names must be declared before they can be used. A name is declared as a host-language pointer. In C and C++, transaction names should be declared as long pointers.
The following code illustrates how to declare two transaction names:
EXEC SQL BEGIN DECLARE SECTION; isc_tr_handle t1; isc_tr_handle t2; EXEC SQL END DECLARE SECTION;
Note:
In this example, the transaction declaration occurs within a SQL section declaration. While InterBase does not require that host-language variables occur within a section declaration, putting them there guarantees compatibility with other SQL implementations that do require section declarations.
In this example, the transaction declaration occurs within a SQL section declaration. While InterBase does not require that host-language variables occur within a section declaration, putting them there guarantees compatibility with other SQL implementations that do require section declarations.
Transaction names are usually declared globally at the module level. If a transaction name is declared locally, ensure that:
- The transaction using the name is completely contained within the function where the name is declared. Include an error-handling routine to roll back transactions when errors occur.
ROLLBACK
releases a transaction name, and sets its value toNULL
. - The transaction name is not used outside the function where it is declared.
To reference a transaction name declared in another module, provide an external declaration for it. For example, in C, the external declaration for t1
and t2
might be as follows:
EXEC SQL BEGIN DECLARE SECTION; extern isc_tr_handle t1, t2; EXEC SQL END DECLARE SECTION;