Using Transaction Names

From InterBase

Go Up to DSQL Limitations (Application Requirements)


Many SQL statements support an optional transaction name parameter, used to specify the controlling transaction for a specific statement. Transaction names can be used in DSQL applications, too, but must be set up when an application is compiled. Once a name is declared, it can be directly inserted into a user statement only by the application itself.

After declaration, use a transaction name in an EXECUTE or EXECUTE ­IMMEDIATE statement to specify the controlling transaction, as in the following C code fragment:

. . .
EXEC SQL
BEGIN DECLARE SECTION:
long first, second; /* declare transaction names */
EXEC SQL
END DECLARE SECTION;
. . .
first = second = 0L; /* initialize names to zero */
. . .
EXEC SQL
SET TRANSACTION first; /* start transaction 1 */
EXEC SQL
SET TRANSACTION second; /* start transaction 2 */
printf("\nSQL> ");
gets(userstatement);
EXEC SQL
EXECUTE IMMEDIATE TRANSACTION first userstatement;
. . .

For complete information about named transactions, see Working with Transactions.

Advance To: