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

Statement functions

Last Updated:2023-06-29 06:42:20  Updated
share
What is on this page
OCIStmtExecute
OCIStmtFetch
OCIStmtFetch2
OCIStmtPrepare
OCIStmtPrepare2
OCIStmtRelease
OCIStmtGetPieceInfo
OCIStmtSetPieceInfo

folded

share

OCIStmtExecute

Purpose : You can call this function to execute a prepared statement.

Syntax :

sword OCIStmtExecute ( 
OCISvcCtx *svchp,
OCIStmt *stmtp,
OCIError *errhp,
ub4 iters,
ub4 rowoff,
CONST OCISnapshot *snap_in,
OCISnapshot *snap_out,
ub4 mode );

Parameters :

Parameter Description
svchp(IN) The environment handle.
stmtp(IN) The statement handle.
errhp(IN/OUT) The error handle.
iters(IN) For a non-SELECT statement, iters and rowoff can be used together. The value of iters - rowoff indicates the number of times the statement is executed. For a SELECT statement, iters indicates the number of rows read from the buffer in one execution. If you are uncertain about the number of rows the SELECT statement returns, set iters to 0. If iters is not set to 0, a handle must have been defined for the statement before execution. This means that an address space must have been defined to store variables returned by the SELECT statement.
rowoff(IN) During a multi-row execution, rowoff represents the starting position of the input variable in the array bind. It is a record offset for the purpose of modifying, inserting, or deleting multiple rows. For example, if the bind variable defined is array[100], the value for iters is 80 and the value of rowoff is 20 when the statement is executed, the statement extracts the input value starting from array[20], and the number of times that the statement is executed is 60, which is calculated by subtracting 20 from 80.
snap_in(IN) This parameter is not supported.
snap_out(OUT) This parameter is not supported.
mode(IN) The mode of execution.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

Additional information : The following table describes the modes supported by OceanBase Call Interface (OBCI).

Mode Description
OCI_COMMIT_ON_SUCCESS Commits the transaction after a successful execution.
OCI_DEFAULT The default mode.
OCI_DESCRIBE_ONLY Returns the description.
OCI_EXACT_FETCH Obtains row data.
OCI_PARSE_ONLY Parses the statement.

OCIStmtFetch

Purpose : You can call this function to fetch rows from the result set returned by an SQL statement. After an SQL statement is executed, this function can be called multiple times to return all rows of the result set until the function returns OCI_NO_DATA.

Syntax :

sword OCIStmtFetch (
OCIStmt *stmtp, 
OCIError *errhp, 
ub4 nrows, 
ub2 orientation, 
ub4 mode)

Parameters :

Parameter Description
stmtp(IN) The statement handle.
errhp(IN/OUT) The error handle.
nrows(IN) The number of rows to be fetched.
orientation (IN) The method to fetch rows.
mode(IN) The mode of the operation. OBCI supports only OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_ERROR is returned if the function call failed, OCI_SUCCESS_WITH_INFO is returned if an alert occurred, and OCI_NO_DATA is returned when no data is fetched after the end of the row set is reached.

Additional information : The following table describes the method supported by OBCI to fetch rows.

Method Description
OCI_FETCH_NEXT Fetches the next row from the current cursor position.

OCIStmtFetch2

Purpose : You can call this function to fetch rows from a scrollable result set.

Syntax :

sword OCIStmtFetch2 (
OCIStmt *stmthp,
OCIError *errhp,
ub4 nrows,
ub2 orientation,
sb4 fetchOffset,
ub4 mode );

Parameters :

Parameter Description
stmthp (INOUT) The statement handle.
errhp (INOUT) The error handle.
nrows(IN) The number of rows to be fetched.
orientation(IN) The orientation of the cursor.
fetchOffset(IN) The offset.
mode(IN) The mode of the operation. This parameter is not supported and is ignored.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_ERROR is returned if the function call failed, OCI_SUCCESS_WITH_INFO is returned if an alert occurred, and OCI_NO_DATA is returned when no data is fetched after the end of the row set is reached.

Additional information : The following table describes the cursor orientations supported by OBCI.

Orientation Description
OCI_FETCH_NEXT/OCI_DEFAULT Fetches the next row from the current position.
OCI_FETCH_CURRENT Fetches the current row.
OCI_FETCH_FIRST Fetches the first row in the result set.
OCI_FETCH_LAST Fetches the last row in the result set.
OCI_FETCH_PRIOR Fetches the previous row of the current row in the result set.
OCI_FETCH_ABSOLUTE Fetches a row by its absolute position in the result set.
OCI_FETCH_RELATIVE Fetches a row by its relative position in the result set.

OCIStmtPrepare

Purpose : You can call this function to prepare an SQL statement that you can execute by calling the OCIStmtExecute() function.

Syntax :

sword OCIStmtPrepare ( 
OCIStmt *stmtp,
OCIError *errhp,
CONST text *stmt,
ub4 stmt_len,
ub4 language,
ub4 mode );

Parameters :

Parameter Description
stmtp(IN) The statement handle.
errhp(IN/OUT) The error handle.
stmt(IN) The SQL statement to be executed.
stmt_len(IN) The length of the SQL statement specified in the stmt parameter.
language(IN) A reserved parameter.
mode(IN) The mode of preparation. OBCI supports only OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

OCIStmtPrepare2

Purpose : You can call this function to prepare an SQL statement that you can execute by calling the OCIStmtExecute() function. Make sure that the statement cache is enabled when you call this function.

Syntax :

sword OCIStmtPrepare2 ( 
OCISvcCtx      *svchp,
OCIStmt       **stmthp,
OCIError       *errhp,
const OraText  *stmttext,
ub4             stmt_len,
const OraText  *key,
ub4             keylen,
ub4             language,
ub4             mode );

Parameters :

Parameter Description
svchp(IN) The environment handle.
stmthp(OUT) The statement handle.
errhp(IN) The error handle.
stmttext(IN) The statement text. It has the same semantics as those of the OCIStmtPrepare() function. Therefore, the string must end with NULL.
stmt_len(IN) The length of the SQL statement specified in the stmt parameter.
key(IN) For statement caching only. It is the key used for searching for the statement in the statement cache. If the key is passed in, the statement text and other parameters are ignored and the search is based solely on the key.
keylen(IN) Valid only for statement caching. It indicates the length of the key.
language(IN) A reserved parameter.
mode(IN) The mode of preparation. OBCI supports only OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

OCIStmtRelease

Purpose : You can call this function to release statement handles that you fetched by calling the OCIStmtPrepare2() function.

Syntax :

sword OCIStmtRelease ( 
OCIStmt *stmthp,
OCIError *errhp,
const OraText  *key,
ub4 keylen,
ub4 mode );

Parameters :

Parameter Description
stmtp(IN/OUT) The statement handle.
errhp(IN/OUT) The error handle.
key(IN) Valid only for statement caching. This is the SQL string passed in by the caller. If a NULL key is passed in, the statement will not be tagged.
keylen(IN) The length of the key, valid only for statement caching.
mode(IN) The mode of preparation. OBCI supports only OCI_DEFAULT, which is the default mode.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

OCIStmtGetPieceInfo

Purpose : You can call this function to return the piece information of piecewise operations.

Syntax :

sword OCIStmtGetPieceInfo( 
CONST OCIStmt  *stmtp,
OCIError       *errhp,
dvoid          **hndlpp,
ub4            *typep,
ub1            *in_outp,
ub4            *iterp, 
ub4            *idxp,
ub1            *piecep );

Parameters :

Parameter Description
stmtp(IN/OUT) The statement handle. It returns OCI_NEED_DATA when the statement is executed.
errhp(IN/OUT) The error handle. When an error occurs, it can be passed to the OCIErrorGet() function to obtain the diagnostic information.
hndlpp (OUT) Returns a pointer to the bind or define handle.
typep (OUT) The handle type. You can specify OCI_HTYPE_BIND for a bind handle or OCI_HTYPE_DEFINEfor a define handle.
in_outp (OUT) A reserved parameter.
iterp (OUT) Returns the row number of an operation that involves multiple rows.
idxp (OUT) A reserved parameter.
piecep (OUT) Returns one of the following defined values: OCI_FIRST_PIECE, OCI_NEXT_PIECE, and OCI_LAST_PIECE.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

OCIStmtSetPieceInfo

Purpose : You can call this function to set piece information for a piecewise operation.

Syntax :

sword OCIStmtSetPieceInfo ( 
dvoid             *hndlp,
ub4               type,
OCIError          *errhp,
CONST dvoid       *bufp,
ub4               *alenp, 
ub1               piece,
CONST dvoid       *indp, 
ub2               *rcodep );

Parameters :

Parameter Description
hndlp (IN/OUT) The bind or define handle.
type (IN) The handle type.
errhp(OUT) The error handle. When an error occurs, it can be passed to the OCIErrorGet() function to obtain the diagnostic information.
bufp (IN/OUT) The pointer to the storage that contains the data value.
alenp (IN/OUT) The length of the value or the data block.
piecep (IN) Returns one of the following defined values: OCI_FIRST_PIECE, OCI_NEXT_PIECE, and OCI_LAST_PIECE. This parameter is used only for IN bind variables.
indp (IN/OUT) The indicator.
rcodep (IN/OUT) The return code.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_ERROR is returned if the function call failed.

Previous topic

Bind, define, and describe functions
Last

Next topic

LOB functions
Next
What is on this page
OCIStmtExecute
OCIStmtFetch
OCIStmtFetch2
OCIStmtPrepare
OCIStmtPrepare2
OCIStmtRelease
OCIStmtGetPieceInfo
OCIStmtSetPieceInfo