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

Databases

OceanBase DatabaseOceanBase Cloud OceanBase 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 DataPilot

Connectors and Middleware

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

Databases

OceanBase DatabaseOceanBase Cloud OceanBase 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 DataPilot
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

Embedded SQL in C for OceanBase

V1.1.7Enterprise Edition
  • What's New
  • What is ECOB?
  • ECOB compatibility with Pro*C
  • Install ECOB
  • Data types and variables
    • Overview
    • Supported data types
    • Data type conversion
    • Indicator variable
    • VARCHAR variable
    • Structure
    • String pointer
  • Embedded SQL statements
    • Overview
    • Variable declaration
    • Connect to OceanBase databases
    • Basic SQL statements
    • Prepared statements
    • Stored procedures
    • Cursor
    • Simple dynamic SQL statement
    • ANSI dynamic SQL statements
    • Error handling
      • SQLCA structure
      • WHENEVER statement
    • LOB-related SQL statements
  • Use ECOB
    • Environment preparation
    • Use ECOB
    • Compile the Tuxedo service
  • Command Line Options

Download PDF

Document Feedback
  1. Documentation Center
  2. Embedded SQL in C for OceanBase
  3. V1.1.7

Use ECOB

Last Updated:2026-09-04 08:37:38

Overview
Precompile the PC files
Compile and link the C file

Overview

OceanBase Embedded SQL in C (ECOB) provided by OceanBase is compatible with the Pro*C precompiler of Oracle.

When you develop an application in C language, both ECOB and Pro*C allow you to embed SQL statements in the source code of the application.

Then, the ECOB precompiler preprocesses the source code for complete syntax analysis and translates the embedded SQL statements and commands into calls to the ecoblib runtime library.

After that, ECOB generates a source code file of the application in C language. After the file is compiled and linked by a C compiler, an executable program is generated.

After you install ECOB, you can precompile PC files, and compile and link C files.

Precompile the PC files

If you use the ECOB precompiler to compile PC files to C files, you can separately compile each PC file. In normal cases, you need only to specify the source files to be processed. The following statement shows the commands used to specify the source files to be processed:

ecob example.pc # Generate an example.c file.
cc example.c # Use the C language compiler to compile the file.

The following statement provides an example on how to use the INCLUDE option to specify the path for querying the header file and define a required macro:

 ecob INCLUDE=/home/example/include INCLUDE=/usr/local/include DEFINE=MY_MACRO DEFINE=MY_MACRO=VALUE ONAME=main.c INAME=main.pc

Compile and link the C file

After you use the ECOB precompiler to compile a PC file to a C file, you need to use the C language compiler, such as cc, to compile and link the C file. When you link the C file, you need to use the ecoblib runtime library (libecob.so) and the OceanBase Call Interface (OBCI) library. By default, libobci.so is installed in the /u01/obclient/lib path. The following statement is an example.

-lecob -lobci -lobclnt -L/u01/obclient/lib/

Previous topic

Environment preparation
Last

Next topic

Compile the Tuxedo service
Next
on this page
Overview
Precompile the PC files
Compile and link the C file