Full documentation will be NEWER (?) ready
:(
For Oracle 8.1.5 and later
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.
Download demo project - 8.5 Kb
Download source - 5 KB
For complete sample click here
//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;
}
}
For complete sample click
here
|