OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Call Interface

V2.1.0Enterprise Edition
  • What's New
  • Product Introduction
  • Install OBCI
  • Data types
  • Basic development procedure
  • Development example
  • Load balancing
  • Reference Functions
    • Connect, authorize, and initialize functions
    • Handle and descriptor functions
    • Bind, define, and describe functions
    • Statement functions
    • LOB functions
    • Transaction functions
    • Miscellaneous functions
    • String functions
    • Date and Datetime functions
    • Interval functions
    • Number functions
    • Terminate functions
    • Describe functions
    • Locale functions
    • Define functions
  • Full-link Diagnostic Trace
    • Full-link Diagnostic Trace
    • Full-link Diagnostic Trace of OBCI
    • Sample code

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Call Interface
  3. V2.1.0

Transaction functions

Last Updated:2026-09-04 08:28:32

OCITransCommit
OCITransRollback
OCITransStart
OCITransDetach
OCITransPrepare
OCITransForget

Notice

Transaction-related functions are available only in OceanBase Database V2.2.76 and later versions.

OCITransCommit

Purpose : You can call this function to commit transactions that are associated with specified service context.

Function syntax :

sword OCITransCommit ( 
OCISvcCtx    *svchp,
OCIError     *errhp,
ub4          flags );

Parameters :

Parameter
Description
svchp(IN) A context handle.
errhp(IN/OUT) An error handle.
flags(IN) A flag used for one-phase commit optimization in global transactions. The value can be OCI_DEFAULT or OCI_TRANS_TWOPHASE.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

OCITransRollback

Purpose : You can call this function to roll back the current transaction.

Notice

The current transaction rolled back by this function is defined as the set of statements executed since the last OCITransCommit() call or since the OCISessionBegin() call. If the application is running in object mode, the modified or updated objects in the object cache of this transaction are also rolled back. Do not roll back a global transaction that is not active. Otherwise, an error will be reported.

Function syntax :

sword OCITransRollback ( 
dvoid *svchp, 
OCIError     *errhp,
ub4          flags );

Parameters :

Parameter
Description
svchp(IN) A context handle.
errhp(IN/OUT) An error handle.
flags(IN) A reserved parameter. The value can only be OCI_DEFAULT.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

OCITransStart

Purpose : You can call this function to start a transaction. This function sets the beginning of a global or serializable transaction. If the flags parameter indicates to start a new transaction, the transaction context associated with the service context handle is initialized in this function.

Function syntax :

sword OCITransStart ( 
OCISvcCtx    *svchp, 
OCIError     *errhp, 
uword        timeout,
ub4          flags );

Parameters :

Parameter
Description
svchp (IN/OUT) A context handle.
errhp (IN/OUT) An error handle.
timeout(IN) The transaction timeout value. This parameter is not supported and is ignored.
flags(IN) The flag of a transaction attribute. The values can be OCI_TRANS_NEW, OCI_TRANS_TIGHT, OCI_TRANS_LOOSE, OCI_TRANS_RESUME, OCI_TRANS_READONLY, and OCI_TRANS_SERIALIZABLE. You can specify multiple values.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

The following data structures can be extended and added in the OCITransStart() function:

struct OCISvcCtx
{
  HANDLE_HEADER;
  OraText *username;
  OraText *password;
  OraText *database;
  struct OCIServer *p_server;
  struct OCISession *p_session;
  struct OCITrans *p_trans;
  ub1 in_v8_mode;
  sb1 use_stmt_cache;
  MYSQL *mysql;
  HashMap_t* stmt_cache_map;
};

struct OCITrans {
  HANDLE_HEADER;
  OraText **trans_name;
  ub4 trans_timeout;
  XID *trans_id;
};

XID *trans_id is set by using an OCIAttrSet call:

OCIAttrSet((void  *)svchp, OCI_HTYPE_SVCCTX, (void  *)txnhp2, 0, OCI_ATTR_TRANS, errhp);
gxid.formatID = 1000; /* format id = 1000 */
gxid.gtrid_length = 3; /* gtrid = 123 */
gxid.data[0] = 1; gxid.data[1] = 2; gxid.data[2] = 3;
gxid.bqual_length = 1; /* bqual = 2 */
gxid.data[3] = 2;
OCIAttrSet((void  *)txnhp2, OCI_HTYPE_TRANS, (void  *)&gxid, sizeof(XID), OCI_ATTR_XID, errhp);

OCITransDetach

Purpose : You can call this function to detach a global transaction.

Function syntax :

sword OCITransDetach ( 
OCISvcCtx    *svchp,
OCIError     *errhp,
ub4          flags );

Parameters :

Parameter
Description
svchp (IN/OUT) A context handle.
errhp (IN/OUT) An error handle.
flags(IN) A reserved parameter. The value can only be OCI_DEFAULT.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

OCITransPrepare

Purpose : You can call this function to prepare a global transaction for commit.

Notice

This function is valid only for global transactions. The function returns OCI_SUCCESS_WITH_INFO if the transaction has not made any modifications. The error handle indicates that the transaction is read-only. The flags parameter has not been used.

Function syntax :

sword OCITransPrepare ( 
OCISvcCtx    *svchp, 
OCIError     *errhp,
ub4          flags );

Parameters :

Parameter
Description
svchp (IN/OUT) A context handle.
errhp (IN/OUT) An error handle.
flags(IN) A reserved parameter. The value can only be OCI_DEFAULT.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

OCITransForget

Purpose : You can call this function to cause the server to forget a heuristically completed global transaction. That is, the server deletes the status of the transaction from the pending transaction table of the system.

Function syntax :

sword OCITransForget ( 
OCISvcCtx     *svchp, 
OCIError      *errhp,
ub4           flags );

Parameters :

Parameter
Description
svchp (IN/OUT) A context handle.
errhp (IN/OUT) An error handle.
flags(IN) A reserved parameter. The value can only be OCI_DEFAULT.

Return value : OCI_SUCCESS is returned if the function call succeeded, or OCI_ERROR is returned if the function call failed.

Previous topic

LOB functions
Last

Next topic

Miscellaneous functions
Next
on this page
OCITransCommit
OCITransRollback
OCITransStart
OCITransDetach
OCITransPrepare
OCITransForget