/** * @file: $RCSfile: oracle_process.cpp,v $ * @brief: $IEC 61850 Protocol * * @version: $Revision: 1.1 $ * @date: $Date: 2018/11/24 06:54:51 $ * @author: $Author: lizhongming $ * @state: $State: Exp $ * * @latest: $Id: oracle_process.cpp,v 1.1 2018/11/24 06:54:51 lizhongming Exp $ * */ #include using namespace std; #include #define OTL_ORA11G #include "otlv4.h" // include the OTL 4 header file otl_connect db; // connect object int OTLConnect (const char* pszConnStr) { try { otl_connect::otl_initialize(); // initialize OCI environment db.rlogon(pszConnStr); //db.auto_commit_off ( ); printf ( "CONNECT: OK!\n" ); } catch(otl_exception& p) { // intercept OTL exceptions printf ( "Connect Error: (%s) (%s) (%s)\n",p.msg, p.stm_text, p.var_info ); return -1; } return 0; } int OTLDisconnect() { //db.commit ( ); db.logoff(); printf ( "DISCONNECT: OK!\n" ); return 0; } void insert() // insert rows into table { otl_stream o(50, // buffer size "insert into test_tab values(:f1,:f2)", // SQL statement db // connect object ); char tmp[32]; for(int i=1;i<=100;++i){ sprintf(tmp,"Name%d",i); // the old way (operators >>() / <<()) is available as always: o<=:f and f1<=:f*2", // SELECT statement db // connect object ); // create select stream float f1=0; char f2[31]; // the old way (operators >>() / <<()) is available as always: i<<8; // assigning :f = 8 // C++98/03 compiler while(!i.eof()){ // while not end-of-data i>>f1>>f2; cout<<"f1="<