The XA_END function disassociates the current session from the transaction branch specified in xid.
The transaction manager calls XA_END when a control thread completes a transaction branch or needs to suspend the work on a transaction branch. This occurs when the application completes a part or all of its work. For example, XA_END is called before blocking some event to enable other control threads to work on the branch. After XA_END returns with success, the calling control thread is no longer associated with the branch, but the branch still exists.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
DBMS_XA.XA_END (
xid IN DBMS_XA_XID,
flag IN PLS_INTEGER)
RETURN PLS_INTEGER;
Parameters
| Parameter | Description |
|---|---|
| xid | For more information, see DBMS_XA_XID object type. |
| flag | For more information, see DBMS_XA constants for the flag field of XA_START & XA_END. |
Return values
For more information, see Possible constant return values for DBMS_XA.
The possible error codes are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL, XAER_PROTO, and XA_RB*.
Considerations
You can specify
TMSUCCESSorTMSUSPENDin theflagparameter, and the transaction branch is disassociated from the current session in the detached state if the return value isXA_OK.TMFAILis not supported. You can callXA_ENDwithTMSUCCESSorTMSUSPENDto disassociate the transaction branch specified byxidfrom the current session.If
XA_ENDsucceeds,XA_OKis returned. An application must check the return value and handle error cases. The application can only proceed with other normal operations whenXA_OKis returned.If you execute a
ROLLBACKstatement beforeXA_ENDis called, changes made by the current transaction will be rolled back. However, the context of the transaction is till associated with the current session until you callXA_END.If you execute a
COMMITstatement beforeXA_ENDis called, the following error will be returned:ORA-02089: COMMIT is not allowed in a subordinate session.If you execute a
COMMITorROLLBACKstatement afterXA_ENDis called, the execution does not have any effect on the transaction specified byxidbecause it is no longer associated with the current session. In this case, you can commit the transaction ID or call theXA_ROLLBACKfunction to commit or rollback the transaction specified byxid.