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

Basic development procedure

Last Updated:2024-05-14 09:02:08  Updated
share
What is on this page
Basic structure of an OBCI application
Development procedure of an OBCI application
Process SQL statements
Example

folded

share

In an application, you can call library functions provided by OceanBase Call Interface (OBCI) to manipulate OceanBase Database. To be compatible with Oracle, all OBCI functions are prefixed with OCI and have the same names as Oracle OCI functions. This allows you to manipulate OceanBase Database in existing Oracle applications by calling the same OCI functions, without the need to modify a single line of code.

Basic structure of an OBCI application

The following content describes the basic structure of an OBCI application:

  1. Initialize the OBCI environment and threads.

  2. Allocate necessary handles and data structures.

  3. Establish a connection to the database and create a user session.

  4. Exchange data with the OceanBase server by using SQL statements, and then perform data processing.

  5. End the user session and disconnect from the database.

  6. Release the allocated handles.

Development procedure of an OBCI application

The following figure shows the basic development procedure of an OBCI application. For more information about the code, see Development examples.

Image 766.png

Process SQL statements

One of the most common tasks of an OBCI application is to receive and process SQL statements. This section describes how to process SQL statements by using an OBCI application.

The following figure shows the steps of executing an SQL statement in an OBCI application and the functions called in each step.

Image 767.png

  1. Call the OCIStmtPrepare() or OCIStmtPrepare2() function to prepare an SQL statement.

  2. Bind the SQL statement with variables that need to be passed to the SQL statement. For a DML statement that has input variables, you can call one or more functions, such as OCIBindByPos() and OCIBindByName(), to bind the address of each input variable to the placeholder in the DML statement.

  3. Call the OCIStmrExecute() function to execute the SQL statement. For a DDL statement, its execution ends at this step.

  4. Describe the output data of the SQL statement.

    If necessary, you can call the OCIParamGet() and OCIAttGet() functions to obtain the following attributes of the record read: the number of fields, the data types of the fields, and the maximum length defined for the field data.

  5. Define the output variables.

    If necessary, you can call the OCIDefineByPos() function to define output variables for the data output items of the SQL statement.

    Notice

    Do not define output variables by calling the OCIDefineByPos() function in an anonymous PL/SQL block. This is because you have completed this step during data binding.

  6. Obtain data.

    If necessary, you can call the OCIStmtFetch() function to obtain the result set of a query.

Example

This example describes how OBCI calls functions on a Linux system.

This example shows how to create, delete, insert, update, and query data in the person table.

The oci.h header file of OBCI is used during the compilation, and the libobci.so or libobci.a library file is used in the linking phase.

Notice

If you are creating a dynamic link to libobci.so, you also need to manually install the OBClient RPM package. If you are creating a static link to libobci.a, the OBClient RPM package is not required.

Sample statement:

Static link:
gcc example.c -I/u01/obclient/include -I/usr/include/oracle/11.2/client64/ /u01/obclient/lib/libobci.a -L/usr/local/lib64 -lstdc++ -lpthread -ldl -lm -g -o example

Dynamic link:
gcc example.c -I/u01/obclient/include -I/usr/include/oracle/11.2/client64/ -L/u01/obclient/lib/ -L/usr/local/lib64 -lobci -lobclnt -g -o example

Note

We recommend that you use the header files of the oracle-11.2 client. You can adjust the header files to use based on the path of the include directory in your environment.

Execution output:

export LD_LIBRARY_PATH=/u01/obclient/lib:$LD_LIBRARY_PATH
$./example
PERSONID  NAME      EMAIL
finish fetch data
finish insert tables
PERSONID  NAME      EMAIL
1         obtest    t@ob.com
finish fetch data
PERSONID  NAME      EMAIL
1         test      test@mail
finish fetch data
PERSONID  NAME      EMAIL
finish fetch data

Previous topic

Data types
Last

Next topic

Development example
Next
What is on this page
Basic structure of an OBCI application
Development procedure of an OBCI application
Process SQL statements
Example