OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

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

What's New Product Introduction Install OBCI Data types Basic development procedure Development example Load balancing 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 of OBCI Sample code
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Call Interface
  3. V2.1.0
iconOceanBase Call Interface
V 2.1.0Enterprise Edition

Transaction functions

Last Updated:2023-06-29 06:42:20  Updated
share
What is on this page
OCITransCommit
OCITransRollback
OCITransStart
OCITransDetach
OCITransPrepare
OCITransForget

folded

share

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
What is on this page
OCITransCommit
OCITransRollback
OCITransStart
OCITransDetach
OCITransPrepare
OCITransForget