The X/Open(R) XA Interface is an open standard for coordinating changes to multiple resources, while ensuring the integrity of these changes. Software products known as transaction processing monitors typically use the XA interface, and since DB2 supports this interface, one or more DB2 databases may be concurrently accessed as resources in such an environment. For information about the concepts and implementation of the XA interface support provided by the database manager, refer to the Administration Guide: Planning. To determine if your platform supports the X/Open XA Interface, refer to the Application Building Guide.
Special consideration is required by DB2 when operating in a Distributed Transaction Processing (DTP) environment which uses the XA interface because a different model is used for transaction processing as compared to applications running independent of a TP monitor. The characteristics of this transaction processing model are:
Due to the unique nature of this environment, DB2 has special behavior and requirements for applications coded to run in it:
In a DTP environment, if an RM has initiated a rollback (for instance, due to a system error or deadlock) to terminate its own branch of a global transaction, it must not process any more requests from the same application process until a transaction manager-initiated sync point request occurs. This includes deadlocks that occur within a stored procedure. For the database manager, this means rejecting all subsequent SQL requests with SQLCODE -918 (SQLSTATE 51021) to inform you that you must roll back the global transaction with the transaction manager's sync point service such as using the CICS SYNCPOINT ROLLBACK command in a CICS environment. If for some reason you request the TM to commit the transaction instead, the RM will inform the TM about the rollback and cause the TM to roll back other RMs anyway.
Cursors declared WITH HOLD are supported in XA/DTP environments for CICS transaction processing monitors.
In cases where cursors declared WITH HOLD are not supported, the OPEN statement will be rejected with SQLCODE -30090 (SQLSTATE 25000), reason code 03.
It is the responsibility of the transactions to ensure that cursors specified to be WITH HOLD are explicitly closed when they are no longer required; otherwise they might be inherited by other transactions, causing conflict or unnecessary use of resources.
CONNECT DECLARE DESCRIBE EXECUTE IMMEDIATE (where the first token or keyword is SET but not SET CONSTRAINTS) OPEN CURSOR FETCH CURSOR CLOSE CURSOR PREPARE (where the first token or keyword that is not blank or left parenthesis is SET (other than SET CONSTRAINTS), SELECT, WITH, or VALUES) SELECT...INTO VALUES...INTO
Any other attempts will be rejected with SQLCODE -30090 (SQLSTATE 25000).
The PREPARE statement will only be usable to prepare SELECT statements. The EXECUTE IMMEDIATE statement is also allowed to execute SQL SET statements that do not return any output value, such as the SET SQLID statement from DB2 Universal Database for OS/390.
APIs which internally issue a commit in the database and bypass the two-phase commit process will be rejected with SQLCODE -30090 (SQLSTATE 25000). For a list of these APIs, see Multisite Update Restrictions. These APIs are not supported in a multisite update (Connect Type 2).
If you intend to develop a multithreaded application, you should ensure that only one thread uses SQL, or use a multiprocess design instead to avoid interleaving of SQL statements from different threads within the same unit of work. If a transaction manager supports multiple processes or multithreading, you should configure it to serialize the threads so that one thread will execute to a sync point before another one begins. An example is the XASerialize option of all_operation in AIX/CICS. For more details about the AIX/CICS XAD file which contains this information, refer to the Administration Guide: Planning.
Note that the above restrictions apply to applications running in TP monitor environment which uses the XA interface. If DB2 databases are not defined for use with the XA interface, these restrictions do not apply, however it is still necessary to ensure that transactions are coded in a way that will not leave DB2 in a state which will adversely affect the next transaction to be run.
To produce an executable application, you need to link in the application objects with the language libraries, the operating system libraries, the normal database manager libraries, and the libraries of the TP monitor and transaction manager products.