Ocilib
OCILIB is an open source and cross platform Oracle driver 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
- encapsulates OCI (Oracle Call Interface)
- is the most complete available OCI wrapper
OCILIB is used in applications written in various languages such as C, C++, Objective C, Erlang, PureBasic, Blitz Basic, ...
Compatibilities
OCILIB runs on any platform having an ISO C compliant compiler and supported by Oracle.
Here is the lists of validated configurations.
Platforms
- Windows, Linux, HP/UX, Solaris, AIX, Mac OS X, OpenVMS
Compilers
- Microsoft C/C++ compilers, GCC, MinGW, IMB XLC, LabView, Intel compilers, Various CCs
Features
General
- Pure ISO code
- Easy API (JDBC's like)
- Cross platform
- Compatible with all Oracle versions >= 8i
- Full Unicode support
- Supports static / shared oracle linkage
- Supports runtime loading of ORTacle shared libraries
- Error handling (global and thread contextual)
- Small memory usage
Library
OCILIB supports all Oracle SQL and PL/SQL datatypes :
- Scalar types : C90 CHAR2, 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 et UROWIDs
Features
- More than 500 simple functions
- Full support for OCI relational API
- Supports most of OCI object API
- Host variable binding
- Array interface binding
- Connection pooling
- Scrollable cursors
- Supports Direct Path API
- Supports "Returning into" DML feature
- Reusable Statements
- Global transactions
- Access columns by index or name
- Provides Hash tables support
- Provides portable threads and mutexes API
- Provides “All in one” Formatted functions (printf’s like)
- Describe database objects
Documentation
Tutorials
- Article about OCILIB on www.codeguru.com : "Faster and Friendlier Access to Oracle's OCI API"
- French Tutorial on www.developpez.com : "Développer une application Oracle en C/C++ avec la librairie OCILIB"
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;
}