Skip Headers

Oracle® C++ Call Interface Programmer's Guide
10g Release 1 (10.1)

Part Number B10778-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page

Go to previous page
Go to next page
View PDF

9 Oracle XA Library

The Oracle XA library is an external interface that allows transaction managers other than the Oracle server to coordinate global transactions. XA library use supports non-Oracle resource managers, in distributed transactions. This is particularly useful in transactions between several databases and resources.

The implementation of the Oracle XA library conforms to the X/Open Distributed Transaction Processing (DTP) software architecture's XA interface specification. The Oracle XA Library is installed as part of the Oracle Database Enterprise Edition.

This chapter contains these topics:

Application Development with XA and OCCI

For connection, disconnection, and transaction control on Oracle databases, applications must interface with a transaction manager. OCCI has APIs for interacting with Environment and Connection objects within XA and make them available for Oracle database access, such as SELECT queries, DML statements, object access, and so on.

Example 9-1 How to Use Transaction Managers with XA

/* Transaction manager opens connection to the Oracle server*/
tpopen("oracle_xa+acc=p/SCOTT/TIGER+sestm=10", 1, TMNOFLAGS);
/* Transaction manager issues XA commands to start a global transaction*/
/* Access the underlying Oracle database using OCCI */
Environment *xaenv = Environment::getXAEnvironment(
Connection *xaconn = xaenv->getXAConnection(
/* Use the Environment & Connection objects */
Statement *stmt = xaconn->createStatement(
   "Update Emp set sal = sal * 0.2");


/* Release the Environment & Connection objects */

APIs for XA Support

The following methods of the Environment Class support use of XA libraries:

In addition, the getXAErrorCode() method should be used by XA enabled applications to determine if thrown exceptions are due to an SQL error (XA_OK) or an XA error (an XA error code).