XA FAQ

From Oracle FAQ
Jump to: navigation, search

Oracle XA connectivity FAQ (Oracle's implementation of the X/Open Distributed Transaction Processing (DTP) XA interface):

What is Oracle XA and what can it be used for?[edit]

Oracle XA is Oracle's implementation of the X/Open Distributed Transaction Processing (DTP) XA interface. The XA standard specifies a bidirectional interface between resource managers (like Oracle) that provide access to shared resources within transactions, and between a transaction service that monitors and resolves transactions.

The XA Application Program Interface (API) is typically used to enable an Oracle database to interact with a transaction processing (TP) monitor, such as:

How does one install Oracle XA?[edit]

No installation is required. Oracle is XA compliant by default. Oracle7 (with the Distributed Option) and all Oracle8 and above releases of the Oracle RDBMS supports XA transactions.

For Oracle 7.3 databases one needs to run the "XAVIEW.SQL" SQL script as user SYS. This script will create the V$XATRANS$ view. Grant select access on it to PUBLIC. This script is located in the $ORACLE_HOME/rdbms/admin directory.

Please note, XAVIEW.SQL is not required for XA applications running on Oracle8 and above.

How does one write XA programs?[edit]

The XA API is supported from both Pro*C and Oracle OCI (Oracle Call Interfaces). Look at the sample precompiler applications that ships with the Oracle database server.

Client:

tx_begin();                 /* Begin transaction boundary */
tpm_service("Service1");    /* Call Service 1 */
tpm_service("Service2");    /* Call Service 2 */
tx_commit();                /* Commit the transaction */

Server:

Service1() {
  // Get service specific data...
  EXEC SQL UPDATE ....;
  // Return service status back to the client...
}
Service2() {
  // Get service specific data...
  EXEC SQL UPDATE ....;
  ...
  // Return service status back to client...
}

Can one use SQL Commit and Rollback statements in XA programs?[edit]

SQL COMMIT and ROLLBACK statements are used to control transactions in a RM (Resource Manager) like Oracle if one doesn't use a TPM (Transaction Processing Monitor). One should to use the TPM's "Transaction Defining Interface" to control transactions in a TPM environment, as there may be other resources involved in the transaction. An example of this is CICS's EXEC CICS SYNCPOINT.

Where can one get more info about Oracle XA?[edit]