IIapi_prepareCommit() Function--Begin Two-phase Commit of Transaction
The IIapi_prepareCommit() function prepares to commit a distributed transaction started with IIapi_query() or IIapi_batch(), or restarted by IIapi_connect().
IIapi_prepareCommit() secures resources for a transaction in a two-phase commit situation. When IIapi_prepareCommit() completes successfully, the server has allocated and secured all resources to commit the transaction. The application can then call IIapi_commit() to commit the transaction or IIapi_rollback() to abort the transaction.
Normally two-phase commits are desirable when multiple transactions are being committed as a unit. Each transaction is secured for the commit with IIapi_prepareCommit(). When all transactions have been secured, the application calls IIapi_commit() to finish the two-phase commit process. If some of the transactions cannot be secured, resulting in an unsuccessful completion of IIapi_prepareCommit(), the application can call IIapi_rollback() on each transaction to abort it.
In order to create or restart a distributed transaction, the application calls IIapi_registerXID() to register a unique global transaction ID. This global transaction ID can be used for multiple transactions. The transaction ID handle returned by IIapi_registerXID() can then be provided as input to IIapi_query(), IIapi_batch(), or IIapi_connect() to create or restart a distributed transaction. The application used the transaction handle returned by IIapi_query(), IIapi_batch(), or IIapi_connect() as input to IIapi_prepareCommit() to specify the distributed transaction for which resources are to be secured.
IIapi_prepareCommit() rejects any transaction handle representing a non-distributed or autocommit transaction.
This function has the following syntax:
II_VOID IIapi_prepareCommit (IIAPI_PREPCMTPARM *prepCommitParm);
typedef struct _IIAPI_PREPCMTPARM
{
IIAPI_GENPARM pr_genParm;
II_PTR pr_tranHandle;
} IIAPI_PREPCMTPARM;
This function has the following parameters:
pr_genParm
Type: input and delayed output
pr_tranHandle
Type: input
Specifies the transaction handle identifying the transaction for the two-phase commit. The value for this handle is from the qy_tranHandle of IIapi_query(), ba_tranHandle of IIapi_batch(), or co_tranHandle parameter in IIapi_connect().
Last modified date: 01/30/2023