int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db1.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC db2.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC db3.rlogon("UID=scott;PWD=tiger;DSN=freetds_mssql"); // connect to ODBC db2.set_transaction_isolation_level(otl_tran_read_uncommitted); db3.set_transaction_isolation_level(otl_tran_read_committed); otl_cursor::direct_exec ( db1, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db1, "create table test_tab(f1 int, f2 varchar(30))" ); // create table db1.commit(); // committing the DDLs to the database insert(); // insert records into table cout<<"=======> Reading uncommitted data..."<<endl; select_nolock(db2); // select records from table db1.commit(); // committing the inserted rows to the database cout<<"=======> Reading committed data..."<<endl; select_committed(db3); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db1.logoff(); // disconnect from ODBC db2.logoff(); // disconnect from ODBC db3.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("uid=scott;pwd=tiger;dsn=mssql2008"); // connect to ODBC otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30), f3 text)" ); // create table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tigger@sybsql"); // connect to ODBC db.auto_commit_on(); otl_cursor::direct_exec(db,"drop procedure my_proc",0); otl_cursor::direct_exec (db, "CREATE PROCEDURE my_proc " " @A int out, " " @B varchar(60) out, " " @C varchar(60) " "AS " "BEGIN " " SELECT @A=@A+1" " SELECT @B=@C " "END" ); // create stored procedure stored_proc(); // invoking stored procedure } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.code<<endl; // print out error code cerr<<p.var_info<<endl; // print out the variable that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.stm_text<<endl; // print out SQL that caused the error } db.logoff(); // disconnect from the data source return 0; }
int main() { otl_connect::otl_initialize(); // initialize DB2 CLI environment try{ db.rlogon("scott/tiger@db2sql"); // connect to DB2 otl_cursor::direct_exec (db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec (db, "create table test_tab " "(f1 int, f2 varchar(30), f3 int, f4 timestamp, f5 date, f6 time)" ); // create table insert(); // insert records into table select(); // select records from table db.logoff(); // disconnect from DB2 } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } return 0; }
int main() { otl_connect::otl_initialize(); // initialize the database API environment try{ db<<"scott/tiger@mssql2008"; // connect to the database // Send SQL statements to the connect obejct for immediate execution. // Ignore any exception for the first statement. try{ db<<"drop table test_tab"; } catch(otl_exception&){} db<<"create table test_tab(f1 int, f2 varchar(30))"; insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from the database return 0; }
int main() { otl_connect::otl_initialize(); // initialize Informix CLI environment try{ db.rlogon("informix/tigger@informixsql"); // connect to Informix otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30), f3 byte)" ); // create table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Informix return 0; }
int main() { otl_connect::otl_initialize(); // initialize the database API environment try{ db.rlogon("scott/tiger@mssql2008"); // connect to the database otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table db.commit(); otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 ntext)" ); // create table insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from the database return 0; }
int main(int argc,char *argv[]) { otl_connect::otl_initialize(); try{ db.rlogon("casshern/goodbaby@test"); otl_cursor::direct_exec( db, "drop table test_tab", otl_exception::disabled ); otl_cursor::direct_exec( db, "create table test_tab(f1 int,f2 varchar(11))" ); insert(); select(); } catch(otl_exception& p) { cerr << p.msg << endl; cerr << p.stm_text << endl; cerr << p.var_info << endl; } db.logoff(); //disconnect from the database return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db<<"scott/tiger"; // connect to the database // Send SQL statements to the connect obejct for immediate execution. // Ignore any exception for the first statement. try{ db<<"drop table test_tab"; } catch(otl_exception&){} db<<"create table test_tab(f1 int, f2 clob)"; db<<"CREATE OR REPLACE PROCEDURE insert_proc " " (A in NUMBER, " " B in out nocopy CLOB) " "IS " "BEGIN " " insert into TEST_TAB (F1, F2) " " values (a, EMPTY_CLOB()) " " returning F2 into B; " "END;"; db<<"CREATE OR REPLACE PROCEDURE update_proc " " (A in NUMBER, " " B in out nocopy CLOB) " "IS " "BEGIN " " select F2 " " into B " " from TEST_TAB " " where F1 = A " " for update nowait; " "END;"; db<<"CREATE OR REPLACE PROCEDURE select_proc " " (A in NUMBER, " " B in out nocopy CLOB) " "IS " "BEGIN " " select F2 " " into B " " from TEST_TAB " " where f1 = A; " "END;"; insert(); // insert records into table update(); // update records in table select(1); // select records from table select(2); // select records from table select(3); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ main_db.rlogon("scott/tigger@freetds_sybsql"); // connect to ODBC main_db.auto_commit_off(); otl_cursor::direct_exec ( main_db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( main_db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into table // opening a secondary connect secondary_db.rlogon (main_db.get_connect_struct().get_henv(), // environment handle to the main database connect main_db.get_connect_struct().get_hdbc() // database connect handle to the main database connect ); // connect to ODBC select(); // select records from table // releasing the secondary connect secondary_db.logoff(); }catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } main_db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize DB2-CLI environment try{ db.rlogon("scott/tiger@db2sql"); // connect to DB2 otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table otl_cursor::direct_exec (db, "DROP PROCEDURE my_proc2", otl_exception::disabled // disable OTL exceptions ); // drop procedure and ignore any errors otl_cursor::direct_exec (db, "CREATE PROCEDURE my_proc2(IN in_f1 INTEGER) " "LANGUAGE SQL " "RESULT SETS 1 " "BEGIN " " DECLARE c1 CURSOR WITH RETURN FOR " " SELECT f1,f2 " " FROM test_tab " " WHERE f1 BETWEEN in_f1 AND in_f1*2; " " OPEN c1; " "END " ); // create stored procedure insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from DB2 return 0; }
int main() { otl_connect::otl_initialize(); // initialize the database environment try{ db.rlogon("scott/tiger"); // connect to the database otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into table } catch(my_base_exception& ex){ // intercept the base exception if(ex.getType()==DB_BASE_EXCEPTION){ // "database exception" is recognized // here, the otl_exception can be analyzed, or simply printed out cerr<<"Database exception:"<<endl; cerr<<"Code: "<<ex.getErrorCode()<<endl; // print out error code cerr<<"Message: " <<reinterpret_cast<const char*>(ex.getErrorMessage()) <<endl; // print out the error message cerr<<"SQL Stm: " <<ex.getErrorSQLStm() <<endl; // print out the SQL Statement cerr<<"Var Info: " <<ex.getErrorVarInfo() <<endl; // print out the bind variable information if(ex.getErrorCode()==32005){ // OTL defined exception cerr<<"Large Input String: " <<ex.getErrorLargeString() <<endl; } }else{ // otherwise, do something else cerr<<"Base exception was caught..."<<endl; } } db.logoff(); // disconnect from the database return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec (db, "CREATE OR REPLACE PACKAGE pkg_test IS " " TYPE my_numeric_table IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; " " TYPE my_varchar_table IS TABLE OF VARCHAR2(128) INDEX BY BINARY_INTEGER; " " /* size is defined in bytes for Oracle 8i... */ " " " " PROCEDURE prc_test(v1 IN OUT my_numeric_table, v2 OUT my_varchar_table); " " " "END; " ); otl_cursor::direct_exec (db, "CREATE OR REPLACE PACKAGE BODY pkg_test IS " " " " PROCEDURE prc_test(v1 IN OUT my_numeric_table, v2 OUT my_varchar_table) " " IS " " BEGIN " " FOR i IN 1..v1.last LOOP " " v1(i) := v1(i)+100; " " END LOOP; " " v1(v1.last+1) := 0; " " v2(1) := 'Hello'; " " v2(2) := 'World'; " " v2(3) := '!!!'; " " END; " " " "END; " ); plsql(); } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tigger@sybsql"); // connect to MS SQL Server otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table otl_cursor::direct_exec ( db, "drop procedure my_proc", otl_exception::disabled // disable OTL exceptions ); // drop old version of stored procedure, if there is one. otl_cursor::direct_exec (db, "CREATE PROCEDURE my_proc " " @F1 int " "AS " "SELECT * FROM test_tab " "WHERE f1>=@F1 AND f1<=@F1*2 " ); // create stored procedure insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from MS SQL Server return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("SCOTT/TIGER@sapdbsql"); // connect to database otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table otl_cursor::direct_exec ( db, "DROP PROCEDURE prc1", otl_exception::disabled // disable OTL exceptions ); otl_cursor::direct_exec ( db, "CREATE DBPROC prc1 (IN f1 int) " "RETURNS CURSOR AS " "$CURSOR = 'CUR1'; " "DECLARE :$CURSOR CURSOR FOR " "SELECT * FROM scott.test_tab WHERE f1 >= :f1 and f1 <= :f1*2; " ); insert(); // insert records into the table select(8); // select records from the table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 varchar2(10))" ); // create table cout<<"========= table with a VARCHAR2 column ========"<<endl; insert(); // insert records into table select(); // select records from table otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 char(10))" ); // create table cout<<"========= table with a CHAR column ========"<<endl; insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger",1); // connect to Oracle in the auto-commit mode. db2.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle db2.logoff(); // disconnect from Oracle return 0; }
int main() { #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher _putenv(const_cast<char*>("NLS_LANG=.AL32UTF8")); // set your Oracle Client NLS_LANG // if its default was set to something else #else putenv(const_cast<char*>("NLS_LANG=.AL32UTF8")); // set your Oracle Client NLS_LANG // if its default was set to something else #endif #else putenv(const_cast<char*>("NLS_LANG=.AL32UTF8")); // set your Oracle Client NLS_LANG // if its default was set to something else #endif otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 nvarchar2(30))" ); // create table insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec (db, "CREATE OR REPLACE PACKAGE pkg_test IS " " TYPE my_date_table IS TABLE OF DATE INDEX BY BINARY_INTEGER; " " " " PROCEDURE prc_test(v IN NUMBER, v2 OUT my_date_table); " " " "END; " ); otl_cursor::direct_exec (db, "CREATE OR REPLACE PACKAGE BODY pkg_test IS " " " " PROCEDURE prc_test(v IN NUMBER, v2 OUT my_date_table) " " IS " " BEGIN " " FOR i IN 1..v LOOP " " v2(i) := SYSDATE-i; " " END LOOP; " " END; " " " "END; " ); plsql(); } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tiger@edbsql"); // connect to EDB otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 varchar2(30))" ); // create table try{ insert1(); // insert records into table }catch(const char* p){ cout<<p<<endl; } cout<<"Selecting the first time around:"<<endl; select(); // select records from table insert2(); cout<<"Selecting the second time around:"<<endl; select(); } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from EDB return 0; }
int main() { otl_connect::otl_initialize(); // initialize the environment try{ db.rlogon("scott/tiger@db2sql"); // connect to the database #ifdef OTL_STREAM_POOLING_ON db.set_stream_pool_size(2); // set the maximum stream pool size and actually initializes // the stream pool. // if this function is not called, the stream pool // gets initialized anyway, with the default size of 32 entries. #endif otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into table for(int i=1;i<=10; ++i){ cout<<"===================> Iteration: "<<i<<endl; select(); // select records from table } } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from the database return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try { db.rlogon("scott/tiger@mssql2008"); // connect to MS SQL Server otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into table } catch(otl_exception& p) { // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE info. cerr<<p.var_info<<endl; // print out the variable that caused the error if(p.arr_len>0) { // checking if the extended fields were populated for(int j=0; j<p.arr_len; ++j) { cout<<"MSG["<<j<<"]="<<p.msg_arr[j]<<endl; // message array cout<<"SQLSTATE["<<j<<"]="<<p.sqlstate_arr[j]<<endl; // sqlstate array cout<<"CODE["<<j<<"]="<<p.code_arr[j]<<endl; // code array } } } db.logoff(); // disconnect from MS SQL Server return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tiger@freetds_mssql"); // connect to the database otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table otl_cursor::direct_exec ( db, "create unique index ind001 on test_tab(f1)" ); // create unique index insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.code<<endl; // print out error code cerr<<p.sqlstate<<endl; // print out error SQLSTATE cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from the database return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tiger@edbsql"); // connect to EDB otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 varchar2(30))" ); // create table insert(); // insert records into table select(); // select records from table } catch(my_base_exception& ex){ // intercept the base exception if(ex.getType()==DB_BASE_EXCEPTION){ // "database exception" is recognized // here, the otl_exception can be analyzed, or simply printed out cerr<<"Database exception:"<<endl; cerr<<"Code: "<<ex.getErrorCode()<<endl; // print out error code cerr<<"Message: "<<ex.getErrorMessage()<<endl; // print out the error message }else{ // otherwise, do something else cerr<<"Base exception was caught..."<<endl; } } db.logoff(); // disconnect from EDB return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("scott/tiger@postgresql"); otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table db.commit(); otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 bool)" ); // create table db.commit(); insert(); // insert records into the table update(10); // update records in the table select(8); // select records from the table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 number, f2 varchar2(30))" ); // create table insert(); // insert records into table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error db.rollback(); // roll back transaction } catch(const char* msg){ cerr<<msg<<endl; // print out the message db.rollback(); // roll back transaction } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize OCI environment try{ db.rlogon("scott/tiger"); // connect to Oracle otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab " "(f1 int, " " f2 timestamp with local time zone, " " f3 timestamp with time zone, " " f4 timestamp)" ); // create table insert(); // insert records into table select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Oracle return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("UID=ygct;PWD=ygct;DSN=dns_mysql_ansi"); // connect to ODBC otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 longblob)" ); // create table insert(); // insert records into table // insert2(); // insert records into table // select(); // select records from table // select3(); // select records from table select2(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("UID=scott;PWD=tiger;DSN=mysql"); // connect to ODBC // db.rlogon("scott/tiger@mysql"); // connect to ODBC, alternative format // of connect string otl_cursor::direct_exec ( db, "drop table test_tab", otl_exception::disabled // disable OTL exceptions ); // drop table otl_cursor::direct_exec ( db, "create table test_tab(f1 int, f2 varchar(30))" ); // create table insert(); // insert records into the table update(10); // update records in the table select(8); // select records from the table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from ODBC return 0; }
int main() { otl_connect::otl_initialize(); // initialize Informix CLI environment try{ db.rlogon("informix/tigger@informixsql"); // connect to Informix select(); // select records from table } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.stm_text<<endl; // print out SQL that caused the error cerr<<p.var_info<<endl; // print out the variable that caused the error } db.logoff(); // disconnect from Informix return 0; }