Oci_tl library is set of classes that simplified access to Oracle database. Low lever wrapper classes provided ultimate fast access to database. It works both in Solaris and Windows (NT ...)  environments.

Classes :

oci_env OCI environment wrapper
oci_db OCI connection wrapper
oci_cursor OCI OCIStmt wrapper
oci_stream nhereted from oci_cursor - provide >> and << operation for variable binding. Manipulator for execution and parsing.
oci_var_string<int _sz=128> Represent string variable for binding
oci_var_int Represent int variable for binding
oci_tl_exception Exception class

Base classes:

oci_var_base
oci_var_base<int _sz=128>

To use the classes you have to use ina_lib namespace;

Sample program:



#include "iostream"
using namespace std;

#include "oci_tl.h"
using namespace ina_lib;

//declare environment
oci_env env;

//declare database (connection)
oci_db db(env);

//queryes see "test.pkg" and "test.pkb" files
const char select_query[]="select * from emp";
const char func_query[]="begin :retval:=test.test_func(:par1,:par2); end;";
const char func_cursor_query[]="begin :retval:=test.test_cursor_func(:par1,:cur1); end;";

void func1()
{
    cout<<"*************************"<<endl;
    cout<<"Select query"<<endl;

    //string variable declaration
    oci_var_string<50> var1,var2,var3,var4;

    //declaring stream (cursor)
    oci_stream str(db);

    //parsing query
    str.parse(select_query);

    //execute query
    str.execute();

    //bind output variables
    str>>var1>>var2>>var3>>var4;

    //fetching resultset
    while(str.fetch())
    {
        cout<<var1.c_str()
            <<":"<<var2.c_str()
            <<":"<<var3.c_str()
            <<":"<<var4.c_str()
            <<endl;
    }

}

void func2()
{
    cout<<"*************************"<<endl;
    cout<<"Test function"<<endl;
	
    //int variable declaration
    oci_var_int var1(":par1"),var2(":par2"),retval(":retval");

    //declaring stream (cursor)
    oci_stream str(db);

    //parsing query
    str.parse(func_query);

    //assigning value
    var1=34;

    //binding variables
    str<<var1<<var2<<retval;

    //execute query
    str.execute();

    //don't have to fetch
    cout<<var1.i_val()
        <<":"<<var2.i_val()
        <<":"<<retval.i_val()
        <<endl;
}

void func3()
{
    cout<<"*************************"<<endl;
    cout<<"Test function - cursor binding"<<endl;

    //int variable declaration
    oci_var_int par1(":par1"),retval(":retval");

    //declaring stream (cursor) to bind
    oci_stream cur1(db,":cur1");

    //output variable declaration
    oci_var_string<> var1,var2,var3,var4;

    //declaring stream (cursor)
    oci_stream str(db);

    //parsing query
    str.parse(func_cursor_query);

    par1=7777;

    //binding variables
    str<<par1<<cur1<<retval;

    //execute query
    str.execute();

    //binding variables to cursor we got
    cur1>>var1>>var2>>var3>>var4;

    //fetching resultset
    while(cur1.fetch())
    {
        cout<<var1.c_str()
            <<":"<<var2.c_str()
            <<":"<<var3.c_str()
            <<":"<<var4.c_str()
            <<endl;
    }


}

int main(int argc, char* argv[])
{
    try
    {
        //login to database
        db.login("SCOTT","TIGER","ORCL");
        
        //function execution
        func1();
        func2();
        func3();
        
        //logout from database
        db.logout();
    }
    //exception handling
    catch(oci_tl_exception& ex)
    {
        cerr<<ex.what()<<endl;
    }
    catch(...)
    {
        cerr<<"Another Error"<<endl;
    }
    return 0;
}


I hope this library will be useful for oracle database access. The oci_tl library home page http://www.inetapi.com/oci_tl

Vasiliy