From Wikipedia, the free encyclopedia
Jump to: navigation, search
Developer(s) Vincent Rogier
Stable release
4.4.1 / November 29, 2017; 10 days ago (2017-11-29)
Written in C, C++
Operating system Cross-platform
Type API
License Apache Version 2.0
Website http://www.ocilib.net/

OCILIB is an open source and cross platform Oracle C and C++ library that delivers fast and reliable access to Oracle databases.

The OCILIB library:

  • offers a rich, full featured and easy to use C API
  • runs on all Oracle platforms
  • is written in pure ISO C code with native ISO C Unicode support
  • provides also a C++ API written in standard C++03
  • encapsulates OCI (Oracle Call Interface)
  • is the most complete available OCI wrapper[citation needed]

OCILIB is used in applications and database layers written in various languages such as C, C++, Objective-C, D, Rust, Go, Swift, Haskell, Erlang, Lisp, PureBasic, Blitz BASIC, Racket and others.


OCILIB runs on any 32 bits and 64 bits platform having an ISO C compliant compiler and supported by Oracle.
The C++ API is pure ISO C++03 and compiles with any C++03 compliant compiler.

Here is the lists of validated configurations.


Validated C Compilers[edit]

OCILIB C API shall compile with any C99 compliant compiler

Validated C++ Compilers[edit]

  • Microsoft C++ compiler
  • G++
  • CLang

OCILIB C++ API shall compile with any C++03 compliant compiler



  • Pure ISO C API
  • Pure ISO C++ API
  • Easy API (JDBC's like)
  • Cross platform
  • Compatible with all Oracle versions >= 8i
  • Full Unicode support (UTF-8 and UTF-16)
  • Supports static / shared oracle linkage
  • Supports runtime loading of Oracle shared libraries
  • Error handling (global and thread contextual)
  • Small memory usage


OCILIB supports all Oracle SQL and PL/SQL datatypes :

  • Scalar types : CHAR, VARCHAR, VARCHAR2, NUMBER, FLOAT, ...
  • binary types : RAW, LONG RAW, VARRAW, ..
  • Larges objects : BLOB, CLOB, NCLOB, BFILE, CFILE
  • LONG types: LONG, VAR LONG, ...
  • Date, Timestamps and Intervals : DATE, TIMESTAMP, INTERVAL
  • PL/SQL types : Ref cursors, PL/SQL Tables
  • Objects (Named Types) and Objects references (REFs)
  • SQL Collections : VARRAYs and Nested Tables
  • ROWIDs and UROWIDs





Example of a complete minimal OCILIB application :

#include "ocilib.h"
int main(int argc, char *argv[])
    OCI_Connection* cn;
    OCI_Statement* st;
    OCI_Resultset* rs;
    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);
    OCI_ExecuteStmt(st, "select intcol, strcol from table");
    rs = OCI_GetResultset(st);
    while (OCI_FetchNext(rs))
        printf("%i - %s\n", OCI_GetInt(rs, 1), OCI_GetString(rs,2));
    return EXIT_SUCCESS;

Example of a complete minimal OCILIB application :

#include "ocilib.hpp"
using namespace ocilib;
int main(void)
        Connection con("db", "usr", "pwd");
        Statement st(con);
        st.Execute("select intcol, strcol from table");
        Resultset rs = st.GetResultset();
        while (rs.Next())
            std::cout << rs.Get<int>(1) << " - " <<  rs.Get<ostring>(2) << std::endl;
    catch(std::exception &ex)
         std::cout << ex.what() << std::endl;
    return EXIT_SUCCESS;

External links[edit]