青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

寶杉的博客

UNIX/LINUX;ACE;SNMP;C++
posts - 33, comments - 23, trackbacks - 0, articles - 0

OTL 4.0, OTL concept

Posted on 2007-08-20 16:58 寶杉 閱讀(2588) 評論(4)  編輯 收藏 引用 所屬分類: OTL

OTL stream concept

Any SQL statement, PL/SQL block or a stored procedure call is characterized by its input / output [variables].

Example 1. A SELECT statement has scalar input variables that are used in the WHERE clause of the statement. The SELECT statement also defines output columns. Potentially, the output columns are vector parameters since the SELECT statement may return multiple rows.

Example 2. An INSERT statement writes data into a table, i.e. it has input parameters. Same is true for UPDATE statemements.

Example 3. A DELETE statement deletes rows from a table. Deletion criteria needs to be entered, thus the DELETE statement has input.

Example 4. A stored procedure may have input and/or output parameters. Usually, stored procedure parameters are scalars. There is a special case, though: stored procedure returning a referenced cursor (Oracle) or a result set (MS SQL Server or Sybase).

Example 5. An arbitrary PL/SQL block may have input or/and output parameters that may be either scalars or vectors.

Industrial strength database servers have bulk (or array) operations:

  • bulk INSERT
  • bulk UPDATE
  • bulk DELETE
  • bulk SELECT

Therefore, parameters in INSERT/UPDATE/DELETE statement may be vectors if the statement is performed in bulk.

The picture is clear: any interaction with SQL or its procedural extension can be treated as a black box with input and/or output. It does not matter what the black box does inside (according to the definition of a black box). What matters is the input wires that send signals into the box and the output wires that receive signals from the box:

Some of the wires may be both input and output.

Why not combine the concept of data streams and SQL? Instead of multiplying constructs and making database API's too convoluted, why not unify and simplify them? The OTL gives an answer to those questions and the answer is the otl_stream class.

Since a SQL statement may be done in bulk, the otl_stream is a buffered stream. Conceptually, the otl_stream has two separate buffers: input and output. The input buffer is comprised of all input variables put together. Respectively, the output buffer is comprised of all output variables put together.

C++ streams are usually manipulated via operator >> and operator <<. The stream reference is on the left of the operator symbol:

   s>>variable;
s<<variable;

The double arrow shows the direction in which data goes:

  • >> -- from the stream into the data container (variable)
  • << -- from the data container (variable) into the stream

OTL streams are similar to buffered C++ streams . A SQL statement or stored procedure call is opened as an ordinary buffered stream. The logic of the OTL stream operations remains the same as the C++ stream operations with the only exception -- the OTL stream has separate input and output buffers which may overlap.

The OTL stream has a flush function for flushing its input buffer when the buffer gets full and a collection of >> and << operators for reading and writing objects of different data types. The most important advantage of the OTL streams is their unified interface to SQL statements and stored procedure call of any kind. This means that the application developer needs to remember just a few syntactical constructs and function names which he already got familiar with when he started working with C++ streams.

Inside the OTL stream there is a small parser for parsing declarations of bind variables and their data types. There is no need to declare C/C++ host variables and bind them with placeholders by special bind function calls. All necessary buffers are created dynamically inside the stream. The stream just needs to be opened for reading and writing values.

The OTL stream interface requires use of the OTL exceptions. This means that potentially any OTL stream operation can throw an exception of the otl_exception type. In order to intercept the exception and prevent the program from aborting, wrap up the OTL stream code with the corresponding try & catch block.

The functioning of the otl_stream is pretty much automatic: when all of the input variables of the stream are defined (in other words, the input buffer is filled out), it triggers the block box inside the stream to execute. The output buffer gets filled out in the process of the execution of the black box. After the execution is finished, the output values can be read from the stream. If it is a SELECT statement and it returns more rows than the output buffer can hold, after the whole output buffer is read, then the stream automatically fetches the next bacth of rows into the output buffer.

Feedback

# re: OTL 4.0, OTL concept  回復  更多評論   

2008-08-06 14:20 by harvey
This example demonstrates a stored procedure call.

Source Code
#include <iostream>using namespace std;#include <stdio.h>#define OTL_ODBC_MSSQL_2005 // Compile OTL 4/ODBC, MS SQL 2005//#define OTL_ODBC // Compile OTL 4/ODBC. Uncomment this when used with MS SQL 7.0/ 2000#include <otlv4.h>otl_connect db; // connect objectvoid stored_proc(void)// invoking stored procedure{ otl_stream o(1, // buffer size should be equal to 1 in case of stored procedure call "{call my_proc(" " :A<int,inout>, " " :B<char[31],out>, " " :C<char[31],in> " ")}", // stored procedure call db // connect object ); o.set_commit(0); // set stream auto-commit off since // the stream does not generate transaction o<<1<<"Test String1"; // assigning :1 = 1, :3 = "Test String1" int a; char b[31]; o>>a>>b; cout<<"A="<<a<<", B="<<b<<endl;}int main(){ otl_connect::otl_initialize(); // initialize ODBC environment try{ db.rlogon("uid=scott;pwd=tiger;dsn=mssql"); // connect to ODBC otl_cursor::direct_exec (db, "CREATE PROCEDURE my_proc " " @A int out, " " @B varchar(60) out, " " @C varchar(60) " "AS " "BEGIN " " SELECT @A=@A+1" " SELECT @B=@C " "END" ); // create stored procedure stored_proc(); // invoking stored procedure } catch(otl_exception& p){ // intercept OTL exceptions cerr<<p.msg<<endl; // print out error message cerr<<p.code<<endl; // print out error code cerr<<p.var_info<<endl; // print out the variable that caused the error cerr<<p.sqlstate<<endl; // print out SQLSTATE message cerr<<p.stm_text<<endl; // print out SQL that caused the error } db.logoff(); // disconnect from the data source return 0;}
Output
A=2, B=Test String1

# re: OTL 4.0, OTL concept  回復  更多評論   

2008-08-06 14:25 by harvey
忘了對以上例子的說明了。

以上是OTL中調用存儲過程,得到出參的例子,OTL說明書里是有的,但我也找了很久才找到的。網址是 http://otl.sourceforge.net/otl3_ex24.htm

需要注意以下
otl_stream o(1, stored procedure call
"{call my_proc("
       " :A<int,inout>, " //
       " :B<char[31],out>, " //
        " :C<char[31],in> " //char[31], 和in之間不能有空格
       ")}",
       db);

# re: OTL 4.0, OTL concept  回復  更多評論   

2008-08-06 14:28 by harvey
這個是OTL調sql, ODBC的,注意是
#define OTL_ODBC

而不是ORACLE的例子

因為otl + oracle的例子網上非常多,
而otl + sqlServer的例子網上很少,

在這希望能起到拋磚引玉的作用。

# re: OTL 4.0, OTL concept  回復  更多評論   

2008-10-14 19:18 by xiao_xiao
我在用到otl_stream時候,我是在流里不斷的輸入,但是如果其中的一條語句錯誤,異常了,他是否會把緩存里面的所有清空刷新呢? 我懷疑這樣我入庫的時候,會少數據呢? 聯系我 165621600
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            女人色偷偷aa久久天堂| 欧美日韩八区| 亚洲黄色大片| 久久欧美肥婆一二区| 欧美一区二区成人| 久久成人国产| 久久夜色精品一区| 亚洲电影免费观看高清完整版在线观看 | 欧美电影电视剧在线观看| 欧美成人激情在线| 亚洲精品国产精品国产自| 亚洲最快最全在线视频| 亚洲女女做受ⅹxx高潮| 久久久久国产一区二区三区四区 | 99国产精品国产精品毛片| 一区二区冒白浆视频| 亚洲专区欧美专区| 老司机午夜精品视频在线观看| 免费在线观看日韩欧美| 欧美日韩在线不卡一区| 国产日韩精品一区二区三区在线 | 亚洲第一网站| 亚洲午夜精品一区二区三区他趣| 欧美一级二区| 欧美区视频在线观看| 国产欧美日韩高清| aa亚洲婷婷| 久久久久久久网| 亚洲免费福利视频| 久久精品夜色噜噜亚洲a∨| 欧美福利网址| 黄色一区二区在线| 亚洲午夜久久久| 毛片一区二区三区| 亚洲视频在线看| 欧美精品粉嫩高潮一区二区| 海角社区69精品视频| 亚洲在线视频免费观看| 亚洲乱码国产乱码精品精98午夜| 亚洲欧美视频在线观看视频| 久久国产精品久久精品国产| 亚洲激情国产| 久久久久久尹人网香蕉| 国产精品一区二区久久国产| 亚洲日本aⅴ片在线观看香蕉| 亚洲一级在线| 亚洲欧洲午夜| 欧美成人精品1314www| 国产欧美在线观看一区| 亚洲图中文字幕| 亚洲国产黄色片| 巨乳诱惑日韩免费av| 国产在线播放一区二区三区| 亚洲欧美日产图| 日韩午夜激情| 欧美日本韩国| 日韩视频一区二区| 欧美国产一区二区三区激情无套| 久久av红桃一区二区小说| 国产精品久久久久久久电影 | 久久久久久久尹人综合网亚洲| 国产精品日韩久久久久| 亚洲中午字幕| 亚洲免费中文字幕| 国产喷白浆一区二区三区| 性亚洲最疯狂xxxx高清| 亚洲自拍高清| 国内激情久久| 美女视频黄a大片欧美| 久久人人精品| 亚洲美女91| 99精品热6080yy久久| 欧美午夜视频在线| 午夜欧美精品久久久久久久| 午夜精品免费| 激情五月综合色婷婷一区二区| 免费成人在线观看视频| 欧美成人r级一区二区三区| 一区二区日韩| 亚洲女爱视频在线| 亚洲国产精品久久久久久女王| 欧美激情va永久在线播放| 欧美激情精品久久久久久| 中文国产亚洲喷潮| 亚洲宅男天堂在线观看无病毒| 国产主播精品| 亚洲人成人99网站| 国产免费亚洲高清| 欧美成人国产一区二区| 欧美日韩日韩| 久久日韩粉嫩一区二区三区| 男人的天堂亚洲在线| 亚洲欧美日韩视频二区| 久久国产精品99精品国产| 亚洲精品1234| 亚洲一区免费视频| 亚洲第一在线综合网站| 亚洲人成在线观看一区二区| 久久精品91久久久久久再现| 久久精品日韩欧美| 99国产精品自拍| 亚洲欧美电影院| 亚洲黑丝在线| 亚洲欧美另类在线| 日韩午夜在线观看视频| 久久不射电影网| 亚洲愉拍自拍另类高清精品| 噜噜噜91成人网| 乱人伦精品视频在线观看| 免费一级欧美在线大片| 亚洲日韩视频| 久久久久久国产精品mv| 亚洲综合激情| 一区二区三区黄色| 亚洲国产精品一区二区www| 久久五月婷婷丁香社区| 国产深夜精品福利| 久久亚洲免费| 国产精品高精视频免费| 亚洲久久一区二区| 亚洲少妇诱惑| 亚洲国产综合视频在线观看| 久久精品国产免费| 国产视频久久久久久久| 91久久在线观看| 激情欧美一区二区三区| 亚洲制服av| 亚洲午夜久久久久久尤物| 欧美va天堂在线| 欧美1区视频| 国内揄拍国内精品久久| 亚洲老司机av| 嫩草国产精品入口| 欧美不卡视频一区发布| 国语自产精品视频在线看| 欧美亚洲视频| 久久精品综合一区| 国产乱码精品1区2区3区| 中日韩美女免费视频网址在线观看 | 国产精品蜜臀在线观看| 亚洲精品视频在线观看免费| 亚洲激情校园春色| 嫩草国产精品入口| 亚洲大片精品永久免费| 亚洲国产精彩中文乱码av在线播放| 欧美诱惑福利视频| 欧美在线不卡视频| 久久av二区| 国产欧美一级| 欧美成年人在线观看| 蜜臀av性久久久久蜜臀aⅴ| 久久久精品国产99久久精品芒果| 亚洲欧美日韩国产精品| 亚洲一区精彩视频| 久久久久久久999精品视频| 久久精品国产综合| 开心色5月久久精品| 国产一区白浆| 国产亚洲精品自拍| 亚洲人成网在线播放| 狠狠爱www人成狠狠爱综合网| 今天的高清视频免费播放成人| 精品99一区二区三区| 国内一区二区在线视频观看| 伊人成年综合电影网| 在线观看欧美日韩| 亚洲深夜福利| 久久精品久久99精品久久| 亚洲无毛电影| 久久成人一区| 在线一区二区三区四区五区| 久久精品日韩| 在线观看欧美一区| 国产精品毛片高清在线完整版| 亚洲图片自拍偷拍| 夜夜爽99久久国产综合精品女不卡| 午夜精品视频| 亚洲调教视频在线观看| 夜夜嗨一区二区| 午夜视频在线观看一区| 久久精品国产一区二区电影| 99成人精品| 欧美视频中文字幕| 亚洲一区二区在线免费观看视频| 欧美中文字幕不卡| 91久久久精品| 欧美国产在线视频| 尤物99国产成人精品视频| 亚洲国产一区二区三区青草影视| 久久久精品午夜少妇| 亚洲午夜在线观看视频在线| 久久噜噜亚洲综合| 今天的高清视频免费播放成人 | 黄色日韩在线| 亚洲国产精品美女| 久久精品91| 加勒比av一区二区| 欧美大片免费观看| 国产精品毛片一区二区三区| 久久福利资源站|