Ejemplo n.º 1
0
void select()
{ 
 otl_long_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream i(5, // buffer size can be > 1
              "select * from test_tab where f1>=:f11<int> and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;

 i<<8<<8; // assigning :f11 = 8, :f12 = 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="<<f1<<", f2="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;
 }

 i<<4<<4; // assigning :f11 = 4, :f12 = 4
   // 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="<<f1<<", f2="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;
 }

}
Ejemplo n.º 2
0
void select()
{ 
 string f2;
 db.set_max_long_size(7000); // set maximum long string size for connect object

 otl_stream i(1, // buffer size needs to be set to 1 for operations with LOBs
              "select * from test_tab where f1>=:f11<int> and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 float f1;

 i<<8<<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="<<f1<<", f2="<<f2[0]<<f2[f2.length()-1]<<", len="
      <<(int)f2.length()<<endl;
 }

 i<<4<<4;
   // 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="<<f1<<", f2="<<f2[0]<<f2[f2.length()-1]<<", len="
      <<(int)f2.length()<<endl;
 }

}
Ejemplo n.º 3
0
void select()
{ 
 otl_long_unicode_string f2(80000); // define long string variable
 db.set_max_long_size(80000); // set maximum long string size for connect object

 otl_stream i(10, // buffer size
              "select f1, f2 "
              "from test_tab "
              "where f1>=:f11<int> "
              " and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;

 i<<8<<8; // assigning :f11 = 8, :f12 = 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="<<f1<<", f2=";
  for(int j=0;j<f2.len();++j)
    if(f2[j]<128)
      cout<<static_cast<char>(f2[j]);
    else
      cout<<static_cast<int>(f2[j])<<" ";
  cout<<endl; 
 }

}
Ejemplo n.º 4
0
void select()
{ 
 string f2;
 db.set_max_long_size(80000); // set maximum long string size for connect object

 otl_stream i(10, // buffer size
              "select f1, f2 "
              "from test_tab "
              "where f1>=:f11<int> "
              " and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;

 i<<8<<8; // assigning :f11 = 8, :f12 = 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="<<f1<<", f2="<<f2<<endl;
 }

}
Ejemplo n.º 5
0
void insert()
// insert rows into table
{ 
  otl_long_unicode_string f2(80000); // define long unicode string variable
 db.set_max_long_size(80000); // set maximum long string size for connect object
 otl_stream o(10, // buffer size 
              "insert into test_tab values(:f1<int>,:f2<varchar_long>) ",
                 // SQL statement
              db // connect object
             );

 for(int i=1;i<=20;++i){
  f2[0]='<';
  f2[1]='T';
  f2[2]='A';
  f2[3]='G';
  f2[4]='>';
  f2[5]=1111; // Unicode character (decimal code of 1111)  
  f2[6]=2222; // Unicode character (decimal code of 2222)
  f2[7]=3333; // Unicode character (decimal code of 3333)  
  f2[8]=4444; // Unicode character (decimal code of 4444)  
  f2[9]='<';
  f2[10]='/';
  f2[11]='T';
  f2[12]='A';
  f2[13]='G';
  f2[14]='>';
  f2.set_len(15);
  o<<i<<f2;
 }

}
Ejemplo n.º 6
0
void update()
// insert rows in table
{ 

 otl_long_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size has to be set to 1 for operations with LOBs
              "update test_tab "
              "   set f2=empty_clob() "
              "where f1=:f1<int> "
              "returning f2 into :f2<clob> ",
                 // SQL statement
              db // connect object
             );

 for(int j=0;j<33000;++j){
  f2[j]='#';
 }

 f2[33000]='?';
 f2.set_len(33001);

 o<<5<<f2; // update row for which f1=5

}
Ejemplo n.º 7
0
void insert()
// insert rows into table
{ 
 db.set_max_long_size(80000); // set maximum long string size for connect object
 otl_stream o(10, // buffer size
              "insert into test_tab values(:f1<int>,:f2<varchar_long>) ",
                 // SQL statement
              db // connect object
             );
OTL_UNICODE_CHAR_TYPE tmp[80001]; // Null terminated Unicode character array.

 for(int i=1;i<=20;++i){
  tmp[0]='<';
  tmp[1]='T';
  tmp[2]='A';
  tmp[3]='G';
  tmp[4]='>';
  tmp[5]=1111; // Unicode character (decimal code of 1111)  
  tmp[6]=2222; // Unicode character (decimal code of 2222)
  tmp[7]=3333; // Unicode character (decimal code of 3333)  
  tmp[8]=4444; // Unicode character (decimal code of 4444)  
  tmp[9]='<';
  tmp[10]='/';
  tmp[11]='T';
  tmp[12]='A';
  tmp[13]='G';
  tmp[14]='>';
  tmp[15]=0;
  OTL_UNICODE_STRING_TYPE tmp_str(tmp);
  o<<i<<tmp_str;
 }

}
Ejemplo n.º 8
0
void select()
{ 
 otl_long_string f2(80000); // define long string variable
 db.set_max_long_size(80000); // set maximum long string size for connect object

 otl_stream i(10, // buffer size. To read XML as CLOBs, it can be set to a size greater than 1
              "select f1, to_clob(f2) "
              "from test_tab "
              "where f1>=:f11<int> "
              " and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;

 i<<8<<8; // assigning :f11 = 8, :f12 = 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="<<f1<<", f2="<<reinterpret_cast<char*>(&f2[0])<<endl;
 }

}
Ejemplo n.º 9
0
void insert()
// insert rows into table
{ 

 db.set_max_long_size(80000); // set maximum long string size for connect object
 otl_stream o(1, // buffer size needs to be set to 1 when varchar_long is used
              "insert into test_tab values(:f1<int>,:f2<varchar_long>) ",
                 // SQL statement
              db // connect object
             );
 char tmp[80001];

 for(int i=1;i<=20;++i){
#if defined(_MSC_VER)
#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
   sprintf_s(reinterpret_cast<char*>(tmp),sizeof(tmp),"<TAG>MyXML%d</TAG>",i);
#else
  sprintf(reinterpret_cast<char*>(tmp),"<TAG>MyXML%d</TAG>",i);
#endif
#else
  sprintf(reinterpret_cast<char*>(tmp),"<TAG>MyXML%d</TAG>",i);
#endif
  int len=static_cast<int>(strlen(tmp));
  otl_long_string f2(tmp,len,len); // define long string variable
  o<<i<<f2;
 }

}
Ejemplo n.º 10
0
void insert(void)
// insert rows into table
{ 

 otl_long_string f2(1000); // define long string variable
 db.set_max_long_size(1000); // set maximum long string size for connect object

 otl_stream o(10, // buffer size
              "insert into test_tab values(:f1<int>,:f2<varchar_long>)", 
                 // SQL statement
              db // connect object
             );

// Total memory consumption for the buffer equals 1000 * 10, 
// max_long_size * buffer size


 for(int i=1;i<=20;++i){
  for(int j=0;j<50;++j)
   f2[j]='*';
  f2[50]='?';
  f2.set_len(51);
  o<<i<<f2;
 }
}
Ejemplo n.º 11
0
void insert()
// insert rows into table
{ 
 db.set_max_long_size(80000); // set maximum long string size for connect object
 otl_stream o(10, // buffer size
              "insert into test_tab values(:f1<int>,:f2<varchar_long>) ",
                 // SQL statement
              db // connect object
             );
 char tmp[80001];

 for(int i=1;i<=20;++i){
  sprintf(tmp,"<TAG>MyXML%d</TAG>",i);
  string tmp_str(tmp);
  o<<i<<tmp_str;
 }

}
Ejemplo n.º 12
0
void select()
{ 
 otl_long_unicode_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream i(10, // buffer size
              "begin "
              "  open :cur for "
              "  select * from test_tab "
              "  where f1>=:f<int> and f1<=:f*2; "
              "end;",
                 // SELECT statement
              db, // connect object
              ":cur" // reference cursor placeholder name
             ); 
   // create select stream
 
 float f1;

 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="<<f1<<", f2="
      <<static_cast<char>(f2[0]) // first 128 characters of Unicode are ASCII
      <<static_cast<char>(f2[f2.len()-1])<<", len="<<f2.len()<<endl;
 }

 i<<4; // assigning :f = 4
   // 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="<<f1<<", f2="<<static_cast<char>(f2[0])
      <<static_cast<char>(f2[f2.len()-1])<<", len="<<f2.len()<<endl;
 }

}
Ejemplo n.º 13
0
void select()
{ 
 db.set_max_long_size(5); // max size + 1 Unicode character for traling NULL
 otl_stream i(50, // buffer size can be > 1
              "select * from test_tab "
              "where f1>=:f11<int> "
              "  and f1<=:f12<int>*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;
 OTL_UNICODE_STRING_TYPE f2;

 i<<8<<8; // assigning :f11 = 8, f12 = 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;
  i>>f2;
  cout<<"f1="<<f1<<", f2=";
   for(size_t j=0;j<f2.length();++j)
     cout<<" "<<f2[j];
   cout<<endl;
 }

 i<<4<<4; // assigning :f11 = 4, :f12 = 4
   // 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="<<f1<<", f2=";
   for(size_t j=0;j<f2.length();++j)
     cout<<" "<<f2[j];
   cout<<endl;
 }

}
Ejemplo n.º 14
0
void select(void)
{ 
 otl_long_string f2(7000); // define long string variable
 db.set_max_long_size(7000); // set maximum long string size for connect object

 otl_stream i(1, // buffer size needs to be set to 1 in case of TEXT columns
              "select * from test_tab",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;


 while(!i.eof()){ // while not end-of-data
  i>>f1>>f2;
  cout<<"f1="<<f1<<", f2="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;
 }

}
Ejemplo n.º 15
0
void select(void)
{ 
 otl_long_string f2(7000); // define long string variable
 db.set_max_long_size(7000); // set maximum long string size for connect object

 otl_stream i(50, // PostgreSQL 8.1 and higher, the buffer can be > 1
              "select * from test_tab",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;


 while(!i.eof()){ // while not end-of-data
  i>>f1>>f2;
  cout<<"f1="<<f1<<", f2="<<f2[0]<<f2[f2.len()-1]<<", len="<<f2.len()<<endl;
 }

}
Ejemplo n.º 16
0
void insert()
// insert rows into table
{ 
 otl_long_unicode_string f2(70000); // define long unicode string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size has to be set to 1 for operations with CLOBs
              "insert into test_tab values(:f1<int>,:f2<varchar_long>)",
                 // SQL statement
              db // connect object
             );

 for(int i=1;i<=20;++i){
  for(int j=0;j<50000;++j)
   f2[j]='*'; // first 128 characters of Unicode are ASCII
  f2[50000]='?'; // first 128 characters of Unicode are ASCII
  f2.set_len(50001);
  o<<i<<f2;
 }

}
Ejemplo n.º 17
0
void insert(void)
// insert rows into table
{ 

 otl_long_string f2(7000); // define long string variable
 db.set_max_long_size(7000); // set maximum long string size for connect object

 otl_stream o(50, // PostgreSQL 8.1 and higher, the buffer can be > 1
              "insert into test_tab values(:f1<int>,:f2<varchar_long>)", 
                 // INSERT statement
              db // connect object
             );


 for(int i=1;i<=10;++i){
  for(int j=0;j<5000;++j)
   f2[j]='*';
  f2[5000]='?';
  f2.set_len(5001);
  o<<i<<f2;
 }
}
Ejemplo n.º 18
0
void insert(void)
// insert rows into table
{ 

 otl_long_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size needs to be set to 1 for long strings
              "insert into test_tab values(:f1<int>,:f2<raw_long>)", 
                 // SQL statement
              db // connect object
             );


 for(int i=1;i<=20;++i){
  for(int j=0;j<50000;++j)
   f2[j]='*';
  f2[50000]='?';
  f2.set_len(50001);
  o<<i<<f2;
 }
}
Ejemplo n.º 19
0
void insert()
// insert rows into table
{

 string f2; 
 db.set_max_long_size(7000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size has to be set to 1 for operations with LOBs
              "insert into test_tab values(:f1<int>,:f2<varchar_long>)",
                 // SQL statement
              db // connect object
             );

 for(int i=1;i<=20;++i){
  f2.assign(5001,' '); 
  for(int j=0;j<5000;++j)
   f2[j]='*';
  f2[5000]='?';
  o<<i<<f2;
 }

}
Ejemplo n.º 20
0
void insert()
// insert rows into table
{ 

 otl_long_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size has to be set to 1 for operations with LOBs
              "insert into test_tab values(:f1<int>,empty_clob()) "
              "returning f2 into :f2<clob> ",
                 // SQL statement
              db // connect object
             );

 for(int i=1;i<=20;++i){
  for(int j=0;j<50000;++j)
   f2[j]='*';
  f2[50000]='?';
  f2.set_len(50001);
  o<<i<<f2;
 }

}
Ejemplo n.º 21
0
void insert()
// insert rows into table
{ 

 otl_long_string f2(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream o(5, // buffer size > 1
              // BLOB as "raw_long" requires setting "BYTEA as LO" in the ODBC driver settings
              "insert into test_tab values(:f1<int>,:f2<raw_long>)",
                 // SQL statement
              db // connect object
             );

 for(int i=1;i<=20;++i){
  for(int j=0;j<50000;++j)
   f2[j]='*';
  f2[50000]='?';
  f2.set_len(50001);
  o<<i<<f2;
 }

}
Ejemplo n.º 22
0
void select()
{ 
 otl_long_unicode_string f2(70000); // define long string variable
 otl_long_unicode_string f3(70000); // define long string variable
 db.set_max_long_size(70000); // set maximum long string size for connect object

 otl_stream i(10, // buffer size 
              "select "
               "  f1, f2, "
               "  f3 :#3<nclob> "
                 // override the default mapping of f3 (from clob)
                 // to nclob
               "from test_tab "
               "where f1>=:f<int> "
               "  and f1<=:f*2",
                 // SELECT statement
              db // connect object
             ); 
   // create select stream
 
 int f1;

 i<<4; // assigning :f = 4
   // 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>>f3;
  cout<<"f1="<<f1;
  cout<<", f2="<<static_cast<char>(f2[0])
      <<static_cast<char>(f2[f2.len()-1])<<", len="<<f2.len();
  cout<<", f3="<<static_cast<char>(f3[0])
      <<static_cast<char>(f3[f3.len()-1])<<", len="<<f3.len();
  cout<<endl;
 }

}
Ejemplo n.º 23
0
void insert()
// insert rows into table
{ 
 db.set_max_long_size(5); // max size + 1 Unicode character for traling NULL
 otl_stream o(1, // buffer size should be set to 1
              "insert into test_tab values(:f1<int>,:f2<varchar_long>)",
              db // connect object
             );

 OTL_UNICODE_CHAR_TYPE tmp[5];
 OTL_UNICODE_STRING_TYPE tmp2;

 for(int i=1;i<=100;++i){
  o<<i;
  tmp[0]=1111; // Unicode character (decimal code of 1111)
  tmp[1]=2222; // Unicode character (decimal code of 2222)
  tmp[2]=3333; // Unicode chracater (decimal code of 3333)
  tmp[3]=4444; // Unicode chracater (decimal code of 4444)
  tmp[4]=0; // Unicode null terminator 
  tmp2=tmp;
  o<<tmp2; 
 }

}
Ejemplo n.º 24
0
void insert(void)
// insert rows into table
{ 

 otl_long_string f2(2000); // define long string variable
 db.set_max_long_size(2000); // set maximum long string size for connect object

 otl_stream o(1, // buffer size should be 1
              "insert into test_tab values(:f1<int>,:f2<raw_long>)", 
                 // SQL statement
              db // connect object
             );
  o.set_commit(0); // set stream's "auto-commit" to OFF
 
 for(int i=1;i<=20;++i){
  for(int j=0;j<1000;++j)
   f2[j]='*';
  f2[1000]='?';
  f2.set_len(1001);
  o<<i<<f2;
 }
 o.flush(); // flushing thes tream's buffer
 db.commit(); // committing transaction
}