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

Interval functions

Last Updated:2024-05-14 09:02:08  Updated
share
What is on this page
OCIIntervalAdd
OCIIntervalAssign
OCIIntervalCheck
OCIIntervalCompare
Additional information
OCIIntervalDivide
OCIIntervalFromNumber
OCIIntervalFromText
OCIIntervalGetDaySecond
OCIIntervalGetYearMonth
OCIIntervalMultiply
OCIIntervalSetDaySecond
OCIIntervalSetYearMonth
OCIIntervalSubtract
OCIIntervalToNumber
OCIIntervalToText

folded

share

OCIIntervalAdd

Purpose : You can call this function to add two intervals to generate a resulting interval.

Syntax :

sword OCIIntervalAdd ( void         *hndl, 
OCIError     *err, 
OCIInterval  *addend1, 
OCIInterval  *addend2, 
OCIInterval  *result );

Parameters :

Parameter Description
hndl (IN) The Oracle Call Interface (OCI) user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
addend1 (IN) An interval to be added.
addend2 (IN) An interval to be added.
result (OUT) The resulting interval, which equals addend1 + addend2.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalAssign

Purpose : You can call this function to copy one interval to another interval.

Syntax :

void OCIIntervalAssign ( void              *hndl, 
OCIError          *err, 
const OCIInterval *inpinter, 
OCIInterval       *outinter );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
inpinter (IN) The input interval.
outinter (OUT) The output interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalCheck

Purpose : You can call this function to check the validity of an interval.

Syntax :

sword OCIIntervalCheck ( void               *hndl,
OCIError            *err,
const OCIInterval   *interval,
ub4                 *valid );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
interval (IN) The interval to be checked.
valid (OUT) Returns 0 if the interval is valid.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalCompare

Purpose : You can call this function to compare two intervals.

Syntax :

sword OCIIntervalCompare (void          *hndl, 
OCIError      *err,
OCIInterval   *inter1, 
OCIInterval   *inter2, 
sword         *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
inter1 (IN) An interval for comparison.
inter2 (IN) An interval for comparison.
result (OUT) The comparison result. For more information, see Additional information in this section.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

Additional information

Comparison result Output
inter1<inter2 -1
inter1=inter2 0
inter1>inter2 1

OCIIntervalDivide

Purpose : You can call this function to divide an interval by an Oracle NUMBER to generate a new interval.

Syntax :

sword OCIIntervalDivide ( void         *hndl, 
OCIError     *err, 
OCIInterval  *dividend, 
OCINumber    *divisor, 
OCIInterval  *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
dividend (IN) The interval that serves as the dividend.
divisor (IN) The Oracle NUMBER that serves as the divisor.
result (OUT) The resulting interval (dividend/divisor).

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalFromNumber

Purpose : You can call this function to convert an Oracle NUMBER to an interval.

Syntax :

sword OCIIntervalFromNumber ( void               *hndl, 
OCIError           *err,
OCIInterval        *interval,
OCINumber          *number );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
interval (OUT) The resulting interval.
number (IN) The Oracle NUMBER to be converted, in the unit of year for YEAR TO MONTH intervals and in the unit of day for DAY TO SECOND intervals.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalFromText

Purpose : You can call this function to return the interval that a given interval string represents. The result descriptor indicates the interval type.

Syntax :

sword OCIIntervalFromText ( void           *hndl, 
OCIError       *err, 
const OraText  *inpstring,
size_t         str_len,
OCIInterval    *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
inpstring (IN) The input string.
str_len (IN) The length of the input string.
result (OUT) The resulting interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalGetDaySecond

Purpose : You can call this function to obtain the day, hour, minute, and second values from an interval.

Syntax :

sword OCIIntervalGetDaySecond (void               *hndl, 
OCIError           *err, 
sb4                *dy, 
sb4                *hr,
sb4                *mm, 
sb4                *ss, 
sb4                *fsec, 
const OCIInterval  *interval );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
dy (OUT) The number of days.
hr (OUT) The number of hours.
mm (OUT) The number of minutes.
ss (OUT) The number of seconds.
fsec (OUT) The number of nanoseconds.
interval (IN) The input interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalGetYearMonth

Purpose : You can call this function to obtain the year and month values from an interval.

Syntax :

sword OCIIntervalGetYearMonth ( void               *hndl, 
OCIError           *err, 
sb4                *yr,
sb4                *mnth,
const OCIInterval  *interval );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
yr (OUT) The year.
mnth (OUT) The month.
interval (IN) The input interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalMultiply

Purpose : You can call this function to multiply an interval by an Oracle NUMBER to generate another interval.

Syntax :

sword OCIIntervalMultiply ( void               *hndl, 
OCIError           *err, 
const OCIInterval  *inter,
OCINumber          *nfactor,
OCIInterval        *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
inter (IN) The interval to be multiplied.
nfactor (IN) The Oracle NUMBER to be multiplied.
result (OUT) The resulting interval (inter * nfactor).

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalSetDaySecond

Purpose : You can call this function to set the numbers of days, hours, minutes, and seconds in an interval.

Syntax :

sword OCIIntervalSetDaySecond ( void               *hndl, 
OCIError           *err, 
sb4                dy,
sb4                hr,
sb4                mm, 
sb4                ss, 
sb4                fsec, 
OCIInterval        *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
dy (IN) The number of days.
hr (IN) The number of hours.
mm (IN) The number of minutes.
ss (IN) The number of seconds.
fsec (IN) The number of nanoseconds.
result (OUT) The resulting interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalSetYearMonth

Purpose : You can call this function to set the year and month in an interval.

Syntax :

sword OCIIntervalSetYearMonth ( void               *hndl, 
OCIError           *err, 
sb4                yr,
sb4                mnth,
OCIInterval        *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
yr (IN) The year.
mnth (IN) The month.
result (OUT) The resulting interval.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalSubtract

Purpose : You can call this function to subtract one interval by another and stores the result in an interval.

Syntax :

sword OCIIntervalSubtract ( void         *hndl,
OCIError     *err, 
OCIInterval  *minuend, 
OCIInterval  *subtrahend,
OCIInterval  *result );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
minuend (IN) The interval to be subtracted from.
subtrahend (IN) The interval subtracted from minuend.
result (OUT) The resulting interval (minuend - subtrahend).

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

OCIIntervalToNumber

Purpose : You can call this function to convert an interval to an Oracle NUMBER.

Syntax :

sword OCIIntervalToNumber ( void               *hndl, 
OCIError           *err,
OCIInterval        *interval,
OCINumber          *number );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
interval (IN) The interval to be converted.
number (OUT) The resulting Oracle NUMBER, in the unit of year for YEARMONTH intervals and in the unit of day for DAYSECOND intervals.

Return value : OCI_SUCCESS is returned if the function call succeeded, and OCI_INVALID_HANDLE is returned if err is a NULL pointer.

OCIIntervalToText

Purpose : For a given interval, you can call this function to generate a string that represents the interval.

Syntax :

sword OCIIntervalToText ( void               *hndl,
OCIError           *err,
const OCIInterval  *interval,
ub1                 lfprec,
ub1                 fsprec,
OraText             *buf ); 
size_t             buflen,
size_t             *resultlen );

Parameters :

Parameter Description
hndl (IN) The OCI user session handle or environment handle.
err (IN/OUT) The error handle. If any error occurs, it is recorded in err, and the function returns OCI_ERROR. You can call OCIErrorGet to obtain the diagnostic information.
interval (IN) The interval to be converted.
lfprec (IN) The leading field precision, which is used to represent the number of digits of the leading field.
fsprec (IN) The precision of fractional seconds of the interval, which is used to represent the number of digits of the fractional seconds.
buffer (OUT) The buffer for storing the result.
buflen (IN) The length of the buffer.
resultlen (OUT) The length of the result stored in the buffer.

Return value : OCI_SUCCESS is returned if the function call succeeded, OCI_INVALID_HANDLE is returned if err is a NULL pointer, and OCI_ERROR is returned if the function call failed.

Previous topic

Date and Datetime functions
Last

Next topic

Number functions
Next
What is on this page
OCIIntervalAdd
OCIIntervalAssign
OCIIntervalCheck
OCIIntervalCompare
Additional information
OCIIntervalDivide
OCIIntervalFromNumber
OCIIntervalFromText
OCIIntervalGetDaySecond
OCIIntervalGetYearMonth
OCIIntervalMultiply
OCIIntervalSetDaySecond
OCIIntervalSetYearMonth
OCIIntervalSubtract
OCIIntervalToNumber
OCIIntervalToText