KEMBAR78
OracleDB23ai For C Developers | PDF | Databases | Oracle Corporation
0% found this document useful (0 votes)
13 views18 pages

OracleDB23ai For C Developers

ora 23ai for c developers

Uploaded by

Pravin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views18 pages

OracleDB23ai For C Developers

ora 23ai for c developers

Uploaded by

Pravin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Oracle Database 23ai for C

Developers
June, 2025, Version 1.0
Copyright © 2025, Oracle and/or its affiliates
Public
Disclaimer
This document in any form, software, or printed matter, contains proprietary information that is the exclusive
property of Oracle. Your access to and use of this confidential material is subject to the terms and conditions of
your Oracle software license and service agreement, which has been executed and with which you agree to
comply. This document and information contained herein may not be disclosed, copied, reproduced, or
distributed to anyone outside Oracle without prior written consent of Oracle. This document is not part of your
license agreement, nor can it be incorporated into any contractual agreement with Oracle or its subsidiaries or
affiliates.

This document is for informational purposes only and is intended solely to assist you in planning for the
implementation and upgrade of the product features described. It is not a commitment to deliver any material,
code, or functionality, and should not be relied upon in making purchasing decisions. The development, release,
timing, and pricing of any features or functionality described in this document remains at the sole discretion of
Oracle. Due to the nature of the product architecture, it may not be possible to safely include all features
described in this document without risking significant destabilization of the code.

2 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Table of contents

Purpose 4
Introduction 5
AI Vector Search and the VECTOR Data Type 5
The VECTOR Data Type 5
Enriched Development Experience 7
The Native BOOLEAN Data Type 7
SQL Annotations 7
Data Use Case Domains 9
String Indexed PL/SQL Associative Arrays 9
JSON Schema Validation 9
Cloud Computing and Multi-Cloud 9
Centralized Configuration Providers 9
IAM Token-based Authentication with Oracle Cloud 10
OAUTH2 Token-based Authentication with Microsoft Azure 10
Performance and Scalability 11
Pipelining 11
Efficient Table DDL Change Notification 12
Sessionless Transactions 12
Connection Pooling Enhancements 14
Implicit Connection Pooling with DRCP 15
Multi-pool DRCP (Named Pools) 15
Client Result Cache Enhancements 15
Diagnosability 16
Dynamic Client-Side Tracing 16
Session Pool Statistics 16
Security 16
Token-based Authentication with Oracle Cloud’s IAM and Microsoft
Entra ID’s OAUTH2 support 16
Support for Longer Passwords 16
Availability 17
Resumable Cursors and Request Boundaries 17
Conclusion 17

3 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Purpose
This document provides an overview of the major features and enhancements included with Oracle Call Interface
(OCI) C driver that is shipped with the Oracle Database 23ai release. It is intended solely to help you assess the
business benefits of upgrading to 23ai and planning for the implementation and upgrade of the product features
described.

4 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Introduction
This technical brief summarizes the latest and greatest Oracle Call Interface (OCI) features introduced in the
Oracle Database 23ai release. The OCI driver provides APIs to enable C applications to connect and work with
Oracle Database. These new features in OCI address the areas of support for Oracle AI Vector Search, ease of
development, multi-cloud, performance and scalability, mission-critical deployments, security, and availability.

AI Vector Search and the VECTOR Data Type


Oracle Database 23ai introduced a VECTOR data type to store and index vector embeddings for fast retrieval and
similarity searches. A vector is a mathematical representation of data, structured as an ordered list of numbers,
where each number represents a dimension. In simple terms, it is an array of one or more numeric values, i.e.,
integers (e.g., [-2, -1, 0, 1, 2]) or fractional numbers (e.g., [-2.2, -1.1, 0.0, 1.1, 1.1]).

Vectors are widely used to capture important characteristics of unstructured data such as text, images, audio,
videos, and IoT data. Vectors are typically generated using machine learning (ML) embedding models.

Oracle AI Vector Search allows context analysis and similarity search, i.e., the semantic relationship between
objects (words, phrases, images, and so on).

OCI supports all the VECTOR column types: BINARY, INT8 (8-bit integer), FLOAT32 (32-bit floating point
number), and FLOAT64 (64-bit floating point number) in their SPARSE and DENSE representations. All the
floating-point numbers are represented in IEEE format. Here is a sample table with a VECTOR column:

CREATE TABLE my_vectors (id NUMBER, embedding VECTOR(10, INT8));

In this example, each vector in the embedding VECTOR column has 10 dimensions, and each dimension is an 8-
bit integer.

The VECTOR Data Type


OCI provides the new OCIVector descriptor to represent vectors. This descriptor can be allocated and freed
using the OCIDescriptorAlloc() and OCIDescriptorFree() functions, respectively. For reads (OCI
defines) and writes (OCI binds) of OCIVector data, SQLT_VEC is used as the data type constant.

The OCIVectorFromText() and OCIVectorFromArray() functions can be used to populate vector


data in the OCIVector descriptor from a null-terminated C string and from a C array, respectively. The vector
data present in the OCIVector descriptor can be fetched as a null-terminated C string and as a C array using
the OCIVectorToText()and OCIVectorToArray() functions, respectively.

Here is a sample OCI code snippet to select vectors from the my_vectors table created in the earlier section
and fetching the vector data as a string using the OCIVectorToText()function:

OCIEnv *envhp = (OCIEnv *) NULL;

OCIError *errhp = (OCIError *) NULL;

OCISvcCtx *ociSvcCtx = (OCISvcCtx *) NULL;

OCIStmt *ociStmt = (OCIStmt *) NULL;

OCIDefine *defnhp = NULL;

OCIVector *vecp = NULL;

OraText vtext[UB2MAXVAL];

static OraText *selstmt = "SELECT embedding FROM my_vectors ORDER BY id";

ub4 vtextlen;

5 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
size_t str_size;

OCIInd ind1 = 0;

// Set all required handles to establish connection ...

OCIStmtPrepare2(ociSvcCtx, (OCIStmt **)&ociStmt, errhp, selstmt,

(ub4)strlen(selstmt), NULL, 0,

(ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);

OCIDescriptorAlloc(ociEnv, (void**) &vecp, OCI_DTYPE_VECTOR, 0, 0);

OCIDefineByPos2(ociStmt, &defnhp, errhp,1, &vecp, 0, SQLT_VEC, &ind1, NULL, 0,


OCI_DEFAULT);

OCIStmtExecute(ociSvcCtx, ociStmt, errhp, 1, 0, 0, 0, OCI_DEFAULT);

OCIAttrGet(vecp, (ub4)OCI_DTYPE_VECTOR, (void *)&str_size,

(ub4 *)0, (ub4)OCI_ATTR_VECTOR_MAX_STRING_SIZE, errhp);

vtextlen = str_size;

OCIVectorToText(vecp, errhp, &vtext[0], &vtextlen, OCI_DEFAULT);

printf("Vector fetched as Text: %.*s\n", vtextlen, vtext);

// free memory ...

The above snippet prints the vector value returned from the first row of the my_vectors table as a string
representing an array of numbers.

For fetching vector values into an array, the appropriate result array and vector dimension size needs to be set.
See the example below, which uses the OCIVectorToArray()function to fetch INT8 values from the
my_vectors table created in the earlier section:
OCIEnv *envhp = (OCIEnv *) NULL;

OCIError *errhp = (OCIError *) NULL;

OCISvcCtx *ociSvcCtx = (OCISvcCtx *) NULL;

OCIStmt *ociStmt = (OCIStmt *) NULL;

OCIDefine *defnhp = NULL;

OCIVector *vecp = NULL;

OraText vtext[UB2MAXVAL];

static OraText *selstmt = "SELECT embedding FROM my_vectors ORDER BY id";

ub4 vdim = 10; // No. of vector dimensions

int viarr[10]; // For fetching INT8 VECTOR data

int i;

OCIInd ind1 = 0;

// Set all required handles to establish connection ...

OCIStmtPrepare2(ociSvcCtx, (OCIStmt **)&ociStmt, errhp, selstmt,

(ub4)strlen(selstmt), NULL, 0,

(ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
6 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
OCIDescriptorAlloc(ociEnv, (void**) &vecp, OCI_DTYPE_VECTOR, 0, 0);

OCIDefineByPos2(ociStmt, &defnhp, errhp,1, &vecp, 0, SQLT_VEC, &ind1, NULL, 0,


OCI_DEFAULT);

OCIStmtExecute(ociSvcCtx, ociStmt, errhp, 1, 0, 0, 0, OCI_DEFAULT);

OCIVectorToArray(vecp, errhp, OCI_ATTR_VECTOR_FORMAT_INT8, &vdim,

(void *)&(viarr[0]), OCI_DEFAULT);

for (i = 0; i < 10; i++) {

printf("Vector float array [%d]: %d\n", i, viarr[i]);

The above code snippet prints each INT8 vector value returned from the first row of the my_vectors table.

Note that the output array (viarr) size and the vdim value should match the number of vector dimensions of the
vector column being fetched (10 in this case).

See the Oracle Call Interface Vector documentation for more details.

Enriched Development Experience


New features in OCI for simplifying application development include support for the BOOLEAN data type, SQL
Annotations, Data Use Case Domains, string-indexed PL/SQL Associative Arrays, and JSON Schema Validation.
These features enrich the development experience with Oracle Database 23ai.

The Native BOOLEAN Data Type


Oracle Call Interface supports querying and binding of the new ISO SQL standard-compliant BOOLEAN data type.
Using this data type enables applications to represent state more clearly.

For reads (OCI defines) and writes (OCI binds) of SQL BOOLEAN data type, SQLT_BOL is the data type constant.

Below is a sample code snippet for binding a SQL BOOLEAN data type:

#include <stdbool.h>

static text *insStmt = (text *)"INSERT INTO BoolTable(booleanColumn)VALUES


(:booleanColumn)";

OCIBind *bndp = (OCIBind *) 0;

bool boolIn = true;

// example Boolean bind showing relevant parameters for brevity

status = OCIBindByPos(stmthp, &bndp, errhp, 1, (dvoid *) &boolIn, (sword)


sizeof(boolIn), SQLT_BOL, ...);

SQL Annotations
A database table, view or column can be associated with application metadata or annotations thereby allowing
central management of changes. An individual annotation has a name (key) and an optional value.

OCI now supports describing annotations for columns, tables, and views.

7 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Annotations are fetched in OCI as an OCIParam type using the OCIAttrGet() function and
OCI_ATTR_LIST_ANNOTATIONS and OCI_ATTR_NUM_ANNOTATIONS parameter attributes. This returns a list of
annotations. Each annotation is fetched from the annotation list using the OCIParamGet() function. The names
and values of the individual annotations are obtained using OCIAttrGet() function with the
OCI_ATTR_ANNOTATION_KEY and OCI_ATTR_ANNOTATION_VALUE parameter attributes, respectively.

Check for the following sample pseudocode for retrieving annotations in OCI:

OCIParam *paramhp; /* parameter handle */

OCIParam *ann_list; /* list of annotations */

OCIParam *annotation; /* annotation handle */

text *key;

text *value;

ub4 keylen, valuelen;

ub4 num_annotations = 0;

ub4 i;

ub4 status;

// ...

if ((status = OCIAttrGet(paramhp, OCI_DTYPE_PARAM, &num_annotations, 0,

OCI_ATTR_NUM_ANNOTATIONS, errhp)) != OCI_SUCCESS)

// user-defined function (checkerr) to check the error handle and print

// an appropriate error message

checkerr (errhp, status);

if (num_annotations) {

if ((status = OCIAttrGet(paramhp, OCI_DTYPE_PARAM, &ann_list, 0,

OCI_ATTR_LIST_ANNOTATIONS, errhp)) != OCI_SUCCESS)

checkerr (errhp, status);

for (i = 1; i <= num_annotations; ++i) {

if (status = OCIParamGet (ann_list, OCI_DTYPE_PARAM, errhp,

(dvoid **)&annotation, i) != OCI_SUCCESS)

checkerr (errhp, status);

if (status = OCIAttrGet ((dvoid *)annotation, OCI_DTYPE_PARAM, &key,

(ub4 *)&keylen, OCI_ATTR_ANNOTATION_KEY, errhp) != OCI_SUCCESS)

checkerr (errhp, status);

if (status = OCIAttrGet ((dvoid *)annotation, OCI_DTYPE_PARAM, &value,

(ub4 *)&valuelen, OCI_ATTR_ANNOTATION_VALUE, errhp) != OCI_SUCCESS)


8 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
checkerr (errhp, status);

} /* end for loop */

Note: A sample user-defined checkerr() function to check and throw the appropriate OCI error message is
available here.

See the Oracle Call Interface Annotations documentation for more details.

Data Use Case Domains


Oracle Database 23ai introduces Data Use Case Domains, a dictionary object that belongs to a schema and
encapsulates a set of optional properties and constraints for common values, such as credit card numbers or
email addresses. After you define a Data Use Case Domain in the database, you can define table columns to be
associated with that domain, thereby explicitly applying the domain's optional properties and constraints to those
columns.

With Data Use Case Domains, you can define how you intend to use data centrally. They make it easier to ensure
you handle values consistently across applications and improve data quality.

OCI provides two parameter attributes - OCI_ATTR_DOMAIN_NAME and OCI_ATTR_DOMAIN_SCHEMA –


that can be used with the OCIParamGet() function to fetch the Domain name and schema information,
respectively.

String Indexed PL/SQL Associative Arrays


OCI now supports PL/SQL string indexed associative arrays. C applications can natively pass these associative
arrays between the database and the client application allowing for creating, binding, and manipulating of this
collection type. New functions OCICollKeyAssignElem() and OCICollKeyGetElem() have been added to
assign and fetch elements from string-indexed associative arrays, respectively.

This feature enables a more straightforward and less error-prone code development.

JSON Schema Validation


Starting with Oracle Database 23ai, the OCIJsonSchemaValidate() function can be used to perform JSON
schema validation in OCI applications. This returns OCI_SUCCESS on a successful schema validation and
OCI_ERROR otherwise with detailed error messages captured as part of a separate JSON Descriptor for errors.
See the OCI Interface for Schema Validation documentation for more details.

OCI also provides an attribute OCI_ATTR_HAS_JSON_SCHEMA checks to find if a column has an IS JSON schema
constraint.

Cloud Computing and Multi-Cloud


Oracle and Microsoft have been working together to ensure C apps can run across Azure (Apps) and Oracle Cloud
(Autonomous Database) seamlessly. The new features in OCI include Centralized Configuration Provider support
and secure authentication support with tokens across both Oracle Cloud Infrastructure (OCI) and Microsoft Azure
Cloud services.

Centralized Configuration Providers


Centralized Configuration Providers manages all application configurations centrally in a cloud service. It can be
Microsoft Azure-based, or Oracle Cloud Infrastructure-based. The configuration could include the target database
connect descriptor, the database credentials, and a set of performance parameters.
9 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
For database credentials retrieved from a Centralized Configuration Provider to take effect, the username and
password attributes must not be set on the OCI authentication handle (for OCI session pools) or the OCI user
session handle (for standalone connections). If they are set on either handle, then the Centralized Configuration
Provider values are ignored.

For complete details on OCI Centralized Configuration Provider support, see OCI Support for Centralized
Configuration Store documentation.

IAM Token-based Authentication with Oracle Cloud


With the Oracle Database 23ai release, OCI supports Proof of Possession (PoP) access tokens of Oracle Cloud
Infrastructure for IAM1 token-based authentication. The PoP tokens are associated with a public-private key pair.
OCI provides the following attributes for Oracle Cloud’s IAM token authentication that can be set on the
authentication or user session handle:
 OCI_ATTR_IAM_PRIVKEY (mandatory)
 OCI_ATTR_TOKEN (mandatory)
 OCI_ATTR_TOKEN_ISBEARER
 OCI_ATTR_TOKEN_CBK
 OCI_ATTR_TOKEN_CBKCTX
Ensure that the OCI_ATTR_TOKEN_ISBEARER attribute value remains FALSE (default) in the case of Oracle
Cloud’s IAM as it supports only PoP access tokens at the time of writing this document. The IAM token is passed
as an attribute value to OCI_ATTR_TOKEN using the OCIAttrGet() function.

For more details on these attributes, check out the Authentication Information Handle Attributes documentation.

Note that the Oracle Cloud’s IAM tokens are short-lived with a default expiry time of 60 minutes. They need to be
renewed after expiring.

You can pass the Oracle Cloud’s IAM token to the OCI functions in two ways:

 At deployment without application change: The token should be stored in a token file whose location is
provided as an input to the OCI functions. A token file should contain only one token corresponding to an
IAM user.

 Programmatically requiring application change: The token should be provided dynamically as an


attribute-value pair. Check OCI’s IAM Token-based Authentication documentation for more details.

OCI also provides High Availability support for OCI IAM Authentication.

OAUTH2 Token-based Authentication with Microsoft Azure


Oracle Database 23ai OCI supports Bearer OAUTH2 access tokens of Microsoft Azure's Entra ID (formerly
Microsoft Azure Active Directory - AD) for secure, on-demand, password-less authentication.

OCI provides the following attributes for OAUTH2 token authentication that can be set on the authentication
handle or the user session handle:
 OCI_ATTR_TOKEN (mandatory)
 OCI_ATTR_TOKEN_ISBEARER (mandatory and must be set to TRUE)
 OCI_ATTR_TOKEN_CBK
 OCI_ATTR_TOKEN_CBKCTX
Ensure that the OCI_ATTR_TOKEN_ISBEARER attribute value is set to TRUE in the case of Microsoft Entra ID as it
supports only Bearer OAUTH2 access tokens at the time of writing this document. The OAUTH2 token is passed
as an attribute value to OCI_ATTR_TOKEN using the OCIAttrGet() function.

OCI also provides TAF, AC & TAC2 High Availability (HA) support for Microsoft Entra ID’s Bearer OAUTH2 Token
authentication. In the case of a connection failover with tokens present in an external location, the tokens are

1
IAM – Identity Access Management
2
TAF – Transparent Application Failover, TAC – Transparent Application Continuity, AC – Application Continuity
10 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
retrieved by the HA mechanisms of Oracle Database from the token location provided in the connect string or in
the network configuration files.

Performance and Scalability


New features in OCI for performance and scalability include C support for pipelined database operations, Efficient
Table DDL Change Notifications and support for Sessionless Transactions. Also, OCI provides support for the
latest database server-side connection pooling features and client result caching without any code changes in the
OCI applications.

Pipelining
Oracle Database 23ai introduced pipelining support for database operations to boost the overall responsiveness
and throughput of the database connections from various client applications. The basic idea of pipelining is to
keep the database server occupied and allow an application to interleave database requests, responses, and local
work appropriately. Pipelining ensures that both the application and database server idle times are optimized to a
minimum. Pipelined database operations foster an asynchronous programming model, in which an application
user request returns immediately upon submitting a SQL statement for execution without waiting for the
database response.

As the application keeps sending requests, the database server builds up a request queue and executes them one
by one. The server sends the responses back to the application in the same order in which it received the
requests.

The application must ensure that the requests are independent of each other for the pipeline functionality to work
correctly.

The following diagram provides an insight into the internal implementation of OCI’s pipeline support in a sample
scenario:

OCI Pipelining Block Diagram

In the preceding diagram, database requests 1 and 2 have been processed and the responses are being sent
to the application. Database requests 3 to 6 sent by the application are being queued in the database server-
side pipeline. The database will next process request 3 from its pipeline. At the same time, the application
sends request 7 to the queue to be processed.

11 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
OCI provides pipelining APIs and attributes to support this pipelining feature. A new attribute,
OCI_PIPELINE_ENABLE, is introduced to enable pipelining. Pipeline functionality is available only when the
application sets the attribute on the environment. Any call to OCI pipeline function without this mode set, returns
an error.

boolean pipelineEnable = TRUE;

int status;

status = OCIAttrSet((dvoid *) envhp, OCI_HTYPE_ENV,

(dvoid *) &pipelineEnable, (ub4) sizeof(pipelineEnable),

OCI_ATTR_PIPELINE_ENABLE, (OCIError *) errhp));


OCI pipelining uses an explicit block to demarcate the pipelined set of operations. Two new APIs are introduced to
create this explicit pipeline block:
 OCIPipelineBegin(): Indicates the start of the pipeline block of operations.
 OCIPipelineEnd(): Indicates the end of the pipeline block of operations.
The OCIPipelineProcess() API is used to optionally process server responses for pipelined operations
queued on the client side.

See the Oracle Call Interface Pipelining documentation and Veronica Dumitriu’s OCI pipelining blog for more
details.

Efficient Table DDL Change Notification


Table Data Definition Language (DDL) Change Notification provides an efficient mechanism for OCI applications
to subscribe for DDL notifications on database tables of interest. It ensures that OCI applications are notified when
DDL statements make changes to a table. Changes are captured as DDL events, and these events are processed
asynchronously without blocking the user DML activity.

Applications seeking table metadata or caching table metadata in the middle-tier can use Table DDL Change
Notification instead of continuously polling for DDL changes. Thus, applications implementing this feature can
benefit from reduced network round trips to the database.

OCI provides the OCIDdlEventRegister() and OCIDdlEventUnregister() functions to register and


unregister for table DDL change events on a list of tables, list of schemas, or all tables in a database.

OCI also provides DDL Event Descriptor attributes that provides metadata about DDL events, which can be
fetched using the OCIAttrGet() function.

See the Table DDL Change Notification documentation for more details.

Sessionless Transactions
The Sessionless Transactions feature introduced in Oracle Database 23ai enables users to start a transaction on a
database session, submit a unit of work, suspend the transaction, and continue the same transaction on another
session. The coordination is done by passing a user-chosen globally unique transaction identifier. At the end, the
same transaction can be committed from yet another session. Sessionless Transactions can be started on both
the database server side and the client side (like OCI applications).

OCI enables C developers to start, suspend, and resume Sessionless Transactions using its APIs for Transaction
Functions.

As a prerequisite, you must allocate a transaction handle and set it as the OCI_ATTR_TRANS attribute of the
service context handle:

OCISvcCtx *svchp1 = NULL;

OCISvcCtx *svchp2 = NULL;

OCITrans *txnhp = (OCITrans *)0; /* Sessionless transaction */


12 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
OCIError *errhp;

OCIStmt *stmthp;

// Add other handle declarations as required...

sword status;

// Create the 'emp' table earlier


char *sql1 = "INSERT INTO emp VALUES(1, 'Employee One')";

char *gtrid = "global_txid"; // GTRID

// ...

/*

Add code to set up the sessions in the service contexts, svchp1


and svchp2

*/

// ...

/* Allocate the transaction handle and set it on svchp1 */

OCIHandleAlloc(envhp, (void **)&txnhp, OCI_HTYPE_TRANS, 0, 0);


OCIAttrSet(svchp1, OCI_HTYPE_SVCCTX, txnhp, 0, OCI_ATTR_TRANS, errhp);

/* Set the Global Transaction ID (GTRID) on the transaction handle */

OCIAttrSet(txnhp, OCI_HTYPE_TRANS, (void *)gtrid, strlen(gtrid),

OCI_ATTR_TRANS_NAME, errhp);

/* Start the Sessionless Transaction on svchp1 */


// gtrid - "global_txid", timeout - 60 seconds
OCITransStart(svchp1, errhp, 60, OCI_TRANS_SESSIONLESS | OCI_TRANS_NEW);

/* Prepare and execute SQL on svchp1 */

OCIStmtPrepare2(svchp1, &stmthp, errhp, sql1, strlen(sql1), 0, 0,


OCI_NTV_SYNTAX, OCI_DEFAULT);

OCIStmtExecute(svchp1, stmthp, errhp, 1, 0, 0, 0, OCI_DEFAULT);

/* Suspend the Sessionless Transaction on svchp1 */

OCITransDetach(svchp1, errhp, OCI_TRANS_SESSIONLESS | OCI_DEFAULT);

OCIStmtRelease(stmthp, errhp, 0, 0, OCI_DEFAULT);

/* Set the same transaction handle on svchp2 */


OCIAttrSet(svchp2, OCI_HTYPE_SVCCTX, txnhp, 0, OCI_ATTR_TRANS, errhp);

/* Resume the transaction on svchp2 */


OCITransStart(svchp2, errhp, 10, OCI_TRANS_SESSIONLESS | OCI_TRANS_RESUME);

13 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
/* Add code to run other DMLs on svchp2 */

// ...

/* Commit all the transactions from txnhp with svchp2 */


status = OCITransCommit(svchp2, errhp, OCI_DEFAULT);

if (status != OCI_SUCCESS) {

// user-defined function (checkerr) to check the error handle and print

// an appropriate error message

checkerr (errhp, status);

/* Add code to release and detach all handles and free memory */

// ...

Note: A sample user-defined checkerr() function to check and throw the appropriate OCI error message is
available here.

Every Sessionless Transaction is identified by a unique transaction identifier called a Global Transaction ID
(GTRID).

OCI can provide or use an Oracle Database-generated GTRID to identify the Sessionless Transaction to be started.
See Oracle Documentation set a Global Transaction ID (GTRID) using OCI.

OCITransStart() along with the OCI_TRANS_SESSIONLESS | OCI_TRANS_NEW mode and a positive


timeout value starts a Sessionless Transaction in an OCI application.

The OCITransDetach() function with the OCI_TRANS_SESSIONLESS | OCI_DEFAULT flag suspends an


active Sessionless Transaction immediately.

Calling the OCITransStart() function with the OCI_TRANS_SESSIONLESS | OCI_TRANS_RESUME flag


resumes an existing Sessionless transaction:

As of Oracle Database 23ai, Release Update 23.6, when you resume a Sessionless Transaction, the timeout
setting is ignored.

A Sessionless Transaction can be ended by all the usual means that end a local transaction in OCI. For committing
a Sessionless Transaction, OCITransCommit(), and OCIStmtExecute() in OCI_COMMIT_ON_SUCCESS
mode can be used. Sessionless Transactions can be rolled back by all the usual means that end a local transaction
in OCI, such as, OCITransRollback() and OCIRequestEnd().

See the OCI Documentation on Transaction Functions for the complete details.

Connection Pooling Enhancements


Database Resident Connection Pool (DRCP) is a database server-side pool available at the Pluggable Database
(PDB) level or at the Container Database (CDB) level in Oracle Database’s multi-tenant architecture. OCI
applications can work with DRCP, using (SERVER=POOLED) in the connect string.

The major new DRCP features in Oracle Database 23ai include Implicit Connection Pooling and Multi-pool DRCP.
These features require only connect string changes on the OCI application side.

14 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Implicit Connection Pooling with DRCP
Oracle Database 23ai introduced Implicit Connection Pooling with DRCP to enable the database to automatically
release application connections/sessions based on specific boundary requirements in SQL or PL/SQL
transactions and reduce pool management responsibilities on the application.

On the OCI application side, the user just needs to set the POOL_BOUNDARY option in the connect string to enable
it to work with Implicit Connection Pooling. The POOL_BOUNDARY option can have two values:

 STATEMENT – This tells DRCP to perform an 'implicit release' when the database session is stateless
 TRANSACTION – This tells DRCP to perform an 'implicit release' at commit/rollback or when the database
session is stateless. This release will close any active cursors, temporary tables, and temporary LOBs in
case of commit/rollback.
Here is a sample connect string with Implicit Connection Pooling with the STATEMENT POOL_BOUNDARY option:

DBServerPool =

(DESCRIPTION =

(ADDRESS=(PROTOCOL=tcp)(HOST=oraclehost)(PORT=1521))

(CONNECT_DATA=(SERVICE_NAME=db_svc_name)

(SERVER=POOLED)(POOL_BOUNDARY=STATEMENT))

Implicit Connection Pooling with DRCP provides the following benefits for applications:
 Improved scalability for applications through better multiplexing
 Reduced pool handling required on the application side
 Supports higher concurrency for mid-tiers through optimal database resource usage

Multi-pool DRCP (Named Pools)


Oracle Database 23ai introduced Multi-pool DRCP to enable the creation of multiple named pools with different
configurations. OCI applications just need to specify (POOL_NAME=<pool_name>) in the connect string along
with the (SERVER=POOLED) option specified for DRCP to associate a client connection with a particular named
pool. For example:

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraclehost)(PORT=port_number))
(CONNECT_DATA=(SERVICE_NAME=db_service.company.com>)(SERVER=POOLED)
(POOL_NAME=my_pool)))

Multi-pool DRCP provides configuration flexibility to Database Administrators and helps organize the database
connections based on the type of incoming application requests.

Client Result Cache Enhancements


Client Result Cache (CRC) is a memory area inside the application process that caches SELECT query results. Its
presence is invisible to application code, which just executes queries and gets results as normal. Applications that
use Oracle Database drivers and adapters built on OCI libraries - including OCCI, PHP oci8, Python and Node.js
drivers (Thick mode) etc. - can use Client Result Cache to improve response times of repetitive queries.

Starting from Oracle Database 23ai - Release Update 23.7, OCI provides CRC support for

 Client Result Cache support for JSON and VECTOR data


 Client Result Cache support for dictionary queries
 Client Result Cache lag parameter on client side

15 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Diagnosability

Dynamic Client-Side Tracing


C Applications can now enable and disable OCI diagnostic tracing dynamically on the client side. Starting from
Oracle Database 23ai, the diagnostic client-side trace settings for OCI applications can be controlled at runtime
with the help of new APIs:

 OCITraceEventSet()

 OCITraceEventReset()

 OCITraceWriteMessage()

The new dynamic tracing feature also enables developers to write custom messages in the trace files.

These new APIs enable diagnostics to be configured dynamically in the application without the need to update
configuration files or set environment variables.

In earlier OCI versions, diagnostic client-side tracing was enabled/disabled by setting the parameter
EVENT_10842 in the sqlnet.ora network configuration file. Applications had to restart after making any change in
the sqlnet.ora file.

The dynamic client-side tracing feature improves OCI application troubleshooting and reduces problem resolution
time for clients in OCI applications.

Session Pool Statistics


C applications can now get OCI session pool statistics using the OCIAttrGet() function:

 OCI_ATTR_SPOOL_REQ_COUNT - Returns the number of times the OCISessionGet() function is


called on the session pool

 OCI_ATTR_SPOOL_WAIT_TOTAL_COUNT - Returns the total number of accumulated client requests


that had to wait due to the non-availability of free server connections

 OCI_ATTR_SPOOL_WAIT_COUNT - Returns the number of active client requests that are currently
waiting due to the non-availability of free server connections

 OCI_ATTR_SPOOL_HIT_COUNT - Returns the total number of times client requests are found that
match the requests in the session pool out of all the client requests

 OCI_ATTR_SPOOL_HISTMAX_COUNT - Returns the maximum size that the pool has ever reached

Security
The latest set of security-related enhancements in OCI brings in greater password security, entropy, and support
for the latest password complexity rules in Oracle Cloud Database services. C applications can build more secure
solutions with the latest updates in Oracle Database 23ai release.

Token-based Authentication with Oracle Cloud’s IAM and


Microsoft Entra ID’s OAUTH2 support
See the IAM and OAUTH2 Token-based Authentications with Oracle Cloud and Microsoft Azure sections in this
document.

Support for Longer Passwords


Oracle Call Interface (OCI) now supports long passwords up to 1024 bytes, transparently, i.e., no API change is
needed. This is a significant increase from the previous maximum password length of 30 bytes. Increasing the
16 Oracle Database 23ai for C Developers/ Version 1.0
Copyright © 2025, Oracle and/or its affiliates / Public
password length supports an industry-wide trend for stronger authentication, especially for Oracle Cloud services.
This enhancement lets you use passphrase-based authentication, where the customer uses a long sequence of
randomly chosen words to achieve the necessary password entropy.

Availability
Application Continuity (AC) and Transparent Application Continuity (TAC) are high availability and zero-downtime
features of Oracle Database that hide database instance or network failures from C applications. These features
straddle both the database server and OCI client driver.

With AC/TAC, OCI makes high-availability (zero-downtime) the most transparent possible for C applications with
support for resumable cursors and defining explicit request boundaries within a session from Oracle Database
23ai onwards.

Resumable Cursors and Request Boundaries


For Oracle Database 23ai and beyond, OCI introduces the support for Resumable Session State Stable (SSS)
cursors. These are long-running cursors of a session that stay open beyond transactions. With SSS cursors, TAC
establishes application request boundaries, implicitly and more often than older Oracle Database releases, thereby
ensuring broader TAC coverage. An SSS cursor can remain valid for the entire duration of an explicit request and
can be replayed separately from the main request.

The OCI APIs OCIRequestBegin() and OCIRequestEnd() establish explicit request boundaries that
demarcate the beginning and end of an application unit of work, encompassing all session cursors (including SSS
cursors) without use of the OCI Session Pool. Note that OCIRequestBegin() validates the connection by
internally checking the OCI_ATTR_SERVER_STATUS attribute. This attribute is updated based on a lightweight
connection health check inband notifications and FAN event notifications. OCIRequestBegin() initiates failover if
the health check fails and the interval value set in the new OCI_ATTR_PING_INTERVAL attribute is expired.

The session state stability is set and maintained by the new OCI_ATTR_SESSSTATE_CONSISTENCY attribute.
Please check the OCI Documentation on this attribute for more details.

Applications that have their own custom pool implementations (instead of using OCI session pools) for database
connections can call the OCIRequestBegin() and OCIRequestEnd() APIs to to integrate with AC and DRCP.
These applications can also use these APIs to proactively respond to planned maintenance activities by ensuring
that an application request starts with a healthy connection. These methods can also be used with applications
that keep standalone connections open but do not often execute the database operations. However, it is
recommended that applications use OCI session pooling as a preference over custom pools or the
OCIRequestBegin() and OCIRequestEnd() APIs, wherever possible.

Conclusion
Oracle Database 23ai has released an exciting array of new features for Artificial Intelligence, Cloud Operations,
Application Development, Security, and Connection Management that can be leveraged by OCI applications. In
addition to the features mentioned in these documents, OCI can make use of new Oracle Database 23ai
optimizations and features like Fast Connect, Implicit Connection Pooling with DRCP, Multi-pool DRCP etc.
without any application-side code changes. Oracle Database 23ai’s new Error Help URL provides enhanced
troubleshooting capabilities to developers. Overall, these new OCI features will undoubtedly help you design and
deploy modern C applications, which are faster, smarter, and more efficient.

17 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public
Connect with us

Call +1.800.ORACLE1 or visit oracle.com. Outside North America, find your local office at: oracle.com/contact.

blogs.oracle.com facebook.com/oracle twitter.com/oracle

Copyright © 2025, Oracle and/or its affiliates. This document is provided for information purposes only, and the contents hereof are subject to change without notice. This document
is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of
merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are formed either directly or
indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written
permission.

Oracle, Java, MySQL, and NetSuite are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

18 Oracle Database 23ai for C Developers/ Version 1.0


Copyright © 2025, Oracle and/or its affiliates / Public

You might also like