The DBMS_XA package contains the XA/Open interface for applications to call the XA interface in PL.
This package allows application developers to switch or share transactions across OceanBase Client sessions or processes by using PL.
The DBMS_XA subprograms allow PL applications to define a global transaction branch ID (XID) and associate or disassociate the transaction branch with the current session.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Privileges
This package is created under the SYS user. Operations provided by this package are executed by the caller instead of SYS. A DBMS_XA subprogram called from an anonymous PL block is executed with the privileges of the current user. A DBMS_XA subprogram called from a stored procedure is executed with the privileges of the stored procedure owner.
Before you can execute the XA_RECOVER subprogram, you must be granted the SELECT or READ privilege on SYS.DBA_PENDING_TRANSACTIONS.
Considerations
In line with the XA specification of the X/Open CAE Standard for distributed transaction processing, XA_PREPARE, COMMIT, ROLLBACK, or FORGET may not be called when a transaction is associated with the current session. An application can only call XA_PREPARE, COMMIT, ROLLBACK, and FORGET after XA_END is called and the current session is no longer associated with any transaction.
If any transaction is associated with the current session, an XAER_PROTO error is reported from XA_PREPARE, COMMIT, ROLLBACK, or FORGET.
A connection or session to the OceanBase server backend or a resource manager must be established before you can call any subprogram of the package. Resource manager identifiers are not supported. If multiple resource managers are involved, a connection or session must be established for each resource manager before you can call any subprograms of the system package. If multiple connections or sessions are established while a global transaction is being processed, the caller must ensure that all connections and sessions associated with a specific global transaction branch identifier (XID) are established to the same resource manager.
Subprograms
The following table describes the DBMS_XA subprograms supported by the current OceanBase Database version.
| Subprogram | Description |
|---|---|
| DIST_TXN_SYNC | Used for synchronization recovery. OceanBase Database supports this procedure for compatibility only, with no actual operations involved. |
| XA_COMMIT | Commits the global transaction specified by xid. |
| XA_END | Dissociates the current session with the transaction branch specified by xid. |
| XA_FORGET | Informs the resource manager to discard a committed or rolled back transaction branch. |
| XA_GETLASTOER | Returns the last error code if failed XA calls exist. |
| XA_PREPARE | Prepares the transaction branch specified by xid for committing. |
| XA_RECOVER | Obtains from the resource manager a list of transaction branches that are prepared, committed, and rolled back (and whose information is not discarded). |
| XA_ROLLBACK | Informs the resource manager to roll back a transaction branch. |
| XA_SETTIMEOUT | Sets the transaction timeout in seconds for the current session. |
| XA_START | Associates the current session with the transaction branch specified by xid. |