OTL 4.0, Constant SQL statements

Constant SQL statements

A SQL statement / PL/SQL block / stored procedure call is considered to be constant if it does not have any bind variables. OTL 4.0 has a static (in class) function to execute constant statements.

Examples

// static otl_cursor::direct_exec()

  otl_cursor::direct_exec
   (db, // connect object
    "create table test_tab(f1 int, f2 varchar(30))"
    );  // create table
  otl_cursor::direct_exec
   (db, // connect object
    "drop table test_tab", // SQL statement or PL/SQL block
    otl_exception::disabled // disable OTL exceptions,
                            // in other words, ignore any
                            // database error
   ); // drop table

// or otl_connect::direct_exec()

  db.direct_exec // connect object  
("create table test_tab(f1 int, f2 varchar(30))"
   );  // create table

  db.direct_exec // connect object  
    ("drop table test_tab", // SQL statement or PL/SQL block
    otl_exception::disabled // disable OTL exceptions,
                            // in other words, ignore any
                            // database error
   ); // drop table


// or otl_connect::operator<<(const char*)

  db<<"create table test_tab(f1 number, f2 varchar2(30))";
try{
db<<"drop table test_tab""; // SQL statement or PL/SQL block
}catch(otl_exception&){
// ignore a database error
}

otl_cursor is one of the OTL 4.0 internal classes. It is not recommended to use the OTL 4.0 low level classes and functions except for the direct_exec() because it is a special case and it will not be discontinued in the future releases of the OTL.

The direct_exec() function may return the following values of the long int datatype:

Here is an example of the direct_exec(), returning a row processed count:

// static otl_cursor::direct_exec

  long rpc=otl_cursor::direct_exec
            (db, // connect object
             "delete from test_tab where f1>=95"
            ); 

  cout<<"Rows deleted: "<<rpc<<endl;

// or otl_connect:direct_exec

  long rpc=db.direct_exec // connect object
            ("delete from test_tab where f1>=95"
            ); 

  cout<<"Rows deleted: "<<rpc<<endl;



Prev NextContentsGo Home

Copyright © 1996-2023, Sergei Kuchin, email: skuchin@gmail.com, skuchin@gmail.com.

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.