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

Connect, authorize, and initialize functions

Last Updated:2023-06-29 06:42:20  Updated
share
What is on this page
OCIEnvCreate
OCIEnvNlsCreate
OCIEnvInit
OCIInitialize
OCILogoff
OCILogon
OCIServerAttach
OCIServerDetach
OCISessionBegin
OCISessionEnd
OCIPing

folded

share

OCIEnvCreate

Description : You can call this function to create and initialize an environment handle.

Function syntax :

sword OCIEnvCreate ( OCIEnv **envhpp,
ub4 mode,
CONST dvoid *ctxp,
CONST dvoid (malocfp)
(dvoid *ctxp,
size_t size),
CONST dvoid (ralocfp)
(dvoid *ctxp,
dvoid *memptr,
size_t newsize),
CONST void (*mfreefp)
(dvoid *ctxp,
dvoid *memptr))
size_t xtramemsz,
dvoid **usrmempp );

Parameters :

Parameter Description
envhpp(OUT) The pointer to the environment handle that is created.
mode(IN) The mode of initialization. OBCI V1.2.0 supports OCI_DEFAULT (the default mode) and OCI_THREADED (the multi-threaded mode).
ctxp(IN) A parameter reserved for compatibility. Ignore this parameter.
malocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
ralocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
mfreefp(IN) A parameter reserved for compatibility. Ignore this parameter.
xtramemsz(IN) The amount of extra memory to be allocated.
usrmempp(OUT) Returns the address of the extra memory allocated.

Return value : OCI_SUCCESS if succeeded, OCI_ERROR if failed, and OCI_INVALID_HANDLE in the event of an invalid handle.

OCIEnvNlsCreate

Description : You can call this function to create and initialize an environment handle for OCI functions to work under. It is an enhanced version of the OCIEnvCreate() function.

Function prototype :

sword OCIEnvNlsCreate ( OCIEnv **envhpp,ub4 mode,void *ctxp,void *(*malocfp)(void  *ctxp, size_t size),void *(*ralocfp)(void  *ctxp, void  *memptr, size_t newsize),void (*mfreefp)(void  *ctxp, void  *memptr),size_t xtramemsz,void **usrmempp,ub2  charset,ub2  ncharset );

Parameters :

Parameter Description
envp(OUT) An environment handle.
mode(IN) The mode of initialization. OBCI V1.2.0 only supports OCI_DEFAULT, which is the default mode.
ctxp(IN) A parameter reserved for compatibility. Ignore this parameter.
malocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
ralocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
mfreefp(IN) A parameter reserved for compatibility. Ignore this parameter.
xtramemsz(IN) The amount of extra memory to be allocated.
usrmempp(OUT) Returns the address of the extra memory allocated.
charset(IN) The client-end character set for the current environment handle. If the value is 0, the NLS_LANG setting is used. OCI_UTF16ID is a valid setting and is used by the metadata and CHAR data.
ncharset(IN) The national character set at the client end for the current environment handle. If the value is 0, the NLS_ NCHAR setting is used. OCI_UTF16ID is a valid setting and is used by the NCHAR data.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIEnvInit

Description : You can call this function to allocate and initialize an environment handle.

Function prototype :

sword OCIEnvInit ( OCIEnv **envhpp,
    ub4 mode,
    size_t xtramemsz,
    dvoid **usrmempp );

Parameters:

Parameter Description
envp(OUT) An environment handle.
mode(IN) The mode of initialization. OBCI V1.2.0 only supports OCI_DEFAULT, which is the default mode.
xtramem_sz(IN) The amount of extra memory to be allocated.
usrmempp(IN) Returns the address of the extra memory allocated.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIInitialize

Description : You can call this function to initialize the OCI application environment. In this function, OCI initializes internal global variables and loads some configuration information.

Function prototype :

sword OCIInitialize ( ub4 mode,
    const void *ctxp,
    const void *(*malocfp)
    ( void *ctxp,
    size_t size ),
    const void *(*ralocfp)
    ( void *ctxp,
    void *memptr,
    size_t newsize ),
    const void (*mfreefp)
    ( void *ctxp,
    void *memptr ));

Parameters :

Parameter Description
mode(IN) The mode of initialization. OBCI V1.2.0 supports OCI_DEFAULT (the default mode) and OCI_THREADED (the multi-threaded mode).
ctxp(IN) A parameter reserved for compatibility. Ignore this parameter.
malocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
ralocfp(IN) A parameter reserved for compatibility. Ignore this parameter.
mfreefp(IN) A parameter reserved for compatibility. Ignore this parameter.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCILogoff

Description : You can call this function to disconnect a server session created by calling the OCILogon() function.

Function prototype :

sword OCILogoff ( 
    OCISvcCtx *svchp
    OCIError *errhp );

Parameters :

Parameter Description
svchp(IN) Specifies the service context handle associated with the session that you want to disconnect.
errhp(IN/OUT) An error handle.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCILogon

Description : You can call this function to log on to a specified database service with your username and password and initialize the related context handles.

Function prototype :

sword OCILogon ( OCIEnv *envhp,
    OCIError *errhp,
    OCISvcCtx **svchp,
    CONST OraText *username,
    ub4 uname_len,
    CONST OraText *password,
    ub4 passwd_len,
    CONST OraText *dbname,
    ub4 dbname_len );

Parameters :

Parameter Description
envhp(IN) An environment handle.
errhp(IN/OUT) An error handle.
svchp(IN/OUT) A service context handle.
username(IN) The logon username.
uname_len(IN) The length of the logon username.
password(IN) The logon password.
passwd_len(IN) The length of the logon password.
dbname(IN) The name of the database service to connect to.
dbname_len(IN) The length of the database service name.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIServerAttach

Description : You can call this function to attach a database server to a specified connection handle.

Function prototype :

sword OCIServerAttach ( OCIServer *srvhp,
    OCIError *errhp,
    CONST text *dblink,
    sb4 dblink_len,
    ub4 mode );

Parameters :

Parameter Description
srvhp(IN) A server handle that must not be initialized.
errhp(IN/OUT) An error handle.
dblink(IN) The name of the database server to be associated.
dblink_len(IN) The length of the database server name.
mode(IN) The mode of attachment. OBCI V1.2.0 only supports OCI_DEFAULT.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIServerDetach

Description : You can call this function to disassociate a connection handle from a database server.

Function prototype :

sword OCIServerDetach ( OCIServer *srvhp,
    OCIError *errhp,
    ub4 mode );

Parameters :

Parameter Description
srvhp(IN) A server handle that is initialized.
errhp(IN/OUT) An error handle.
mode(IN) The mode of attachment. OBCI V1.2.0 only supports OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCISessionBegin

Description : You can call this function on the specified service context handle to create a session for the specified database server with your logon credentials.

Function prototype :

sword OCISessionBegin ( OCISvcCtx *svchp,
    OCIError *errhp,
    OCISession *usrhp,
    ub4 credt,
    ub4 mode );

Parameters :

Parameter Description
svchp(IN) A handle to the service context on which you want to create the session.
errhp(IN/OUT) An error handle.
usrhp(IN) A handle to the user session context.
credt(IN) The mode of logon. OBCI V1.2.0 only supports OCI_CRED_RDBMS, which enables you to create a session for a database server with your username and password.
mode(IN) The mode of operation. OBCI V1.2.0 only supports OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCISessionEnd

Description : You can call this function to disconnect the session with the database server that you created by calling the OCISessionBegin() function on the specified service context handle.

Function prototype :

sword OCISessionEnd ( OCISvcCtx *svchp,
    OCIError *errhp,
    OCISession *usrhp,
    ub4 mode );

Parameters :

Parameter Description
svchp(IN) Specifies the service context handle to be disconnected.
errhp(IN/OUT) An error handle.
usrhp(IN) A handle to the user session context.
mode(IN) The mode of operation. OBCI V1.2.0 only supports OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

OCIPing

Description : You can call this function to verify that a session and service are active. It succeeds only when the service is active and the session exists.

Function prototype :

sword OCIPing (
OCISvcCtx* svchp,
OCIError* errhp,
ub4 mode)

Parameters :

Parameter Description
svchp (IN) A handle to the service context or session.
errhp (IN/OUT) An error handle.
mode (IN) A time string.

Return value : OCI_SUCCESS if succeeded, or OCI_ERROR if failed.

Previous topic

Load balancing
Last

Next topic

Handle and descriptor functions
Next
What is on this page
OCIEnvCreate
OCIEnvNlsCreate
OCIEnvInit
OCIInitialize
OCILogoff
OCILogon
OCIServerAttach
OCIServerDetach
OCISessionBegin
OCISessionEnd
OCIPing