Was this helpful?
PREPARE TO COMMIT
Valid in: ESQL, OpenAPI, ODBC, JDBC, .NET
The PREPARE TO COMMIT statement polls the local DBMS server to determine the commit status of the local transaction associated with the specified distributed transaction. The distributed transaction is identified by its distributed transaction ID, a unique, 8-byte integer that is generated by the coordinator application.
This statement provides support for the two-phase commit functionality. For a discussion of two-phase commit, see the chapter “Working with Transactions and Handling Errors.”
Dynamic SQL cannot be used to execute this statement. This statement must be terminated according to the rules of your host language.
Note:  The only SQL statements that can follow the PREPARE TO COMMIT statement are COMMIT or ROLLBACK.
The PREPARE TO COMMIT statement has the following format:
EXEC SQL PREPARE TO COMMIT
              WITH HIGHDXID = value, LOWDXID = value;
value
Can be an integer constant or integer variable. The value associated with HIGHDXID must be the high-order 4 bytes of the distributed transaction ID. The value associated with LOWDXID must be the low-order 4 bytes of the distributed transaction ID.
Usage in OpenAPI, ODBC, JDBC, .NET
For OpenAPI, Prepare to Commit functionality is achieved through IIapi_prepareCommit(). For ODBC, JDBC, and .NET, it is supported through interface-specific XA.
Permissions
This statement is available to all users.
Related Statements
COMMIT
ROLLBACK
Last modified date: 04/26/2024