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

Basic development procedure

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

Basic structure of an OBCI application
Development procedure of an OBCI application
Process SQL statements
Example

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
on this page
Basic structure of an OBCI application
Development procedure of an OBCI application
Process SQL statements
Example