Statements that Support Two Phase Commit
SQL provides the following two statements that support two phase commit functionality:
PREPARE TO COMMIT
The PREPARE TO COMMIT statement allows the coordinator application to poll each local DBMS to determine if the local DBMS is ready to commit the local transaction associated with the specified distributed transaction. Using this statement, the coordinator application can ensure that a distributed transaction is committed only if all of the local transactions that are part of the distributed transaction are committed. When the PREPARE TO COMMIT statement successfully completes, the local transaction is in a willing commit state.
CONNECT
The CONNECT statement, when specified with the distributed transaction ID, provides the means for a coordinator application to re-connect to a local DBMS, if the original connection was severed for any reason, for the purposes of committing or aborting a local transaction associated with the specified distributed transaction. When a local transaction is in the willing commit state, the coordinator application controls further processing of that transaction.
Distributed Transaction ID
Both the PREPARE TO COMMIT and the CONNECT statements make use of the distributed transaction ID, an 8-byte integer that must be supplied by the coordinator application. The distributed transaction ID must be a unique number. The local DBMS returns an error to the coordinator application if a specified distributed transaction ID is not unique within the local DBMS.
Last modified date: 01/30/2023