#include #include #include #include #include #define OTL_ORA7 // Compile OTL 3.2/OCI7 #include // include the OTL 3.2 header file EXEC SQL INCLUDE SQLCA; typedef char CSTR[256]; EXEC SQL BEGIN DECLARE SECTION; EXEC SQL TYPE CSTR IS STRING(256); CSTR UserId; EXEC SQL END DECLARE SECTION; void sqlerror(void) { EXEC SQL WHENEVER SQLERROR CONTINUE; fprintf(stderr,"\n%s\n",sqlca.sqlerrm.sqlerrmc); EXEC SQL ROLLBACK RELEASE; exit(1); } EXEC SQL WHENEVER SQLERROR DO sqlerror(); otl_connect db; // connect object 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); o<<(float)i<=:f and f1<=:f*2", // SELECT statement db // connect object ); // create select stream float f1; char f2[31]; i<<8; // assigning :f = 8 // SELECT automatically executes when all input variables are // assigned. First portion of output rows is fetched to the buffer while(!i.eof()){ // while not end-of-data i>>f1>>f2; cout<<"f1="<