zoukankan      html  css  js  c++  java
  • OTL翻译(9) --常量的SQL语句

     常量的SQL语句
    一个没有绑定变量的SQL语句、SQL语句块或是存储过程就被称为常量的SQL语句。OTL通过一个静态的函数来执行这样的SQL语句。
    例如:
    // 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是OTL的一个内部类。它是对direct_exec()函数的一个底层类。因为以后版本该类可能不再对外提供,所以不建议使用。
    下面这个例子为direct_exe()返回结果值的例子:
    // 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;
  • 相关阅读:
    redis 命令
    继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ
    redis Ok2
    ThinkPHP5 清除runtime缓存文件
    linux系统下使用xampp 丢失mysql root密码 只能远程访问,本地无法连接数据库
    yii2 验证规则使用方法
    thinkphp5 模型表关联
    PHP将base64数据流转换成图片并保存
    Win10下80端口被System占用导致Apache无法启动
    3. Git与TortoiseGit基本操作
  • 原文地址:https://www.cnblogs.com/fnlingnzb-learner/p/5903315.html
Copyright © 2011-2022 走看看