OCILIB

OCILIB
Developer(s) Vincent Rogier
Stable release
4.3.0 / November 9, 2016 (2016-11-09)
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:

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.

Compatibilities

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.

Platforms

Validated C Compilers

OCILIB C API shall compile with any C99 compliant compiler

Validated C++ Compilers

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

Features

Library

Datatypes

OCILIB supports all Oracle SQL and PL/SQL datatypes :

Features

Documentation

Tutorials

Example

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;
 
    OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
 
    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));
    }
 
    OCI_Cleanup();
 
    return EXIT_SUCCESS;
}

Example of a complete minimal OCILIB application :

#include "ocilib.hpp"
 
using namespace ocilib;
 
int main(void)
{
    try
    {
        Environment::Initialize();
 
        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;
    }
 
    Environment::Cleanup();
 
    return EXIT_SUCCESS;
}

Bindings

This article is issued from Wikipedia - version of the 11/23/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.