Go Up to DSQL API Limitations
InterBase requires all transaction handles to be declared when an application is compiled. Once fixed at compile time, transaction handles cannot be changed at runtime, nor can new handles be declared dynamically at runtime. Most API functions that process SQL statements at runtime, such as
isc_dsql_prepare(), support the inclusion of a transaction handle parameter. The SQL statements processed by these functions cannot pass transaction handles, even if the SQL syntax for the statement permits the use of a
Before a transaction handle can be used, it must be declared and initialized to zero. The following code declares, initializes, and uses a transaction handle in an API call that allocates and prepares a SQL statement for execution:
#include <ibase.h> . . . isc_tr_handle trans; /* Declare a transaction handle. */ isc_stmt_handle stmt; /* Declare a statement handle. */ char *sql_stmt = "SELECT * FROM EMPLOYEE"; isc_db_handle db1; ISC_STATUS status_vector; . . . trans = 0L; /* Initialize the transaction handle to zero. */ stmt = NULL; /* Set handle to NULL before allocation. */ /* This code assumes that a database attachment is made, * and a transaction is started here. */ . . . /* Allocate the SQL statement handle. */ isc_dsql_allocate_statement(status_vector, &db1, &stmt); /* Prepare the statement for execution. */ isc_dsql_prepare(status_vector, &trans, &stmt, 0, sql_stmt, 1, NULL);
- Previous transactions are first committed or rolled back.
- The transaction handle is set to NULL.