Calling isc_start_transaction()

From InterBase

Go Up to Starting Transactions

Once transaction handles and TPBs are prepared, a transaction can be started by calling isc_start_transaction() following this procedure declaration:

ISC_STATUS isc_start_transaction(ISC_STATUS *status vector,
isc_tr_handle *trans_handle, short db_count, isc_db_handle *&db_handle,
unsigned short tpb_length, char *tpb_ad);

For a transaction that runs against a single database, set db_count to 1. db_handle should be a database handle set with a previous call to isc_attach_database(). tpb_length is the size of the TPB passed in the next parameter, and tpb_ad is the address of the TPB. The following code illustrates a typical call to ­isc_start_transaction():

#include <ibase.h>
. . .
ISC_STATUS status_vector[20];
isc_db_handle db1;
isc_tr_handle tr1;
static char isc_tbp[] = {isc_tpb_version3, isc_tpb_write,
isc_tpb_concurrency, isc_tpb_wait};
. . .
/* Initialize database and transaction handles here. */
db1 = 0L;
tr1 = 0L;
. . .
/* Code for attaching to database here is omitted. */
isc_start_transaction(status_vector, &tr1, 1, &db1,
(unsigned short) zeof(isc_tpb), isc_tpb);

A transaction can be opened against multiple databases. To do so, set the db_count parameter to the number of databases against which the transaction runs, then for each database, repeat the db_handle, tpb_length, and tpb_ad parameters as a group once for each database. For example, the following code fragment assumes that two databases are connected when the transaction is started:

isc_start_transaction(status_vector, &tr1, 2, &db1,
(unsigned short)sizeof(isc_tpb), &tpb1,
&db2, (unsigned short) sizeof(isc_tpb), &tpb2);

See Also

Advance To: