1. Introduction : OpenAPI Concepts and Processes : Transactions
 
Share this page                  
Transactions
A transaction is one or more query statements that make up a logical unit of work. This unit of work is either executed in its entirety, or it is totally or partially rolled back.
With OpenAPI, three types of transactions can occur. They are:
Multi-statement transaction
This type of transaction only affects a single database through a single connection. A transaction is started by IIapi_query() when the qy_tranHandle parameter is NULL. The transaction is committed using IIapi_commit() or rolled back using IIapi_rollback().
Distributed transaction
This type of transaction uses the two-phase commit mechanism to ensure that committal of a distributed transaction occurs in all participating databases through multiple connections.
Distributed transactions are identified by a transaction ID handle returned by IIapi_registerXID(). This handle is used to start transactions on each participating connection by being passed as the qy_tranHandle value when calling IIapi_query(). The transaction ends by calling IIapi_prepareCommit() for each connection followed by IIapi_commit() or IIapi_rollback(). The transaction ID handle is freed by calling IIapi_releaseXID().
Autocommit transaction
This type of transaction causes each individual query to be automatically committed when complete. If a cursor is opened, the commit occurs when the cursor is closed.
Autocommit transactions are started by IIapi_autoCommit() using the connection handle as input. An autocommit transaction ends by calling IIapi_autoCommit() with the autocommit transaction handle as input.
XA transaction
The XA transaction specification is a standardized interface for a distributed transaction processing system. This type of transaction uses a two-phase commit mechanism to ensure that committal of a distributed transaction occurs in all participating databases through multiple connections.
XA transactions are identified by an XA transaction ID. An XA transaction branch is started and associated with a particular connection by calling IIapi_xaStart(). The association is dropped by calling IIapi_xaEnd().
More information:
How Transactions Work