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

寶杉的博客

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>
            日韩网站在线观看| 国产精品欧美一区二区三区奶水| 韩国三级电影久久久久久| 亚洲欧美精品在线观看| 在线一区日本视频| 国产欧美日韩视频一区二区三区 | 欧美激情综合五月色丁香| 亚洲区免费影片| 日韩一区二区精品在线观看| 欧美性片在线观看| 久久精品观看| 免费美女久久99| 亚洲伊人色欲综合网| 亚洲欧美视频在线观看视频| 国产日韩欧美另类| 欧美激情精品久久久久久蜜臀 | 一区二区三区日韩精品| 国产日产亚洲精品| 亚洲国内自拍| 欧美三级欧美一级| 久久这里只有| 欧美色网一区二区| 美女视频黄a大片欧美| 欧美日韩成人在线| 麻豆成人在线观看| 欧美色欧美亚洲另类二区| 久久久久国产精品麻豆ai换脸| 欧美不卡一区| 久久精品国产亚洲5555| 欧美激情第一页xxx| 欧美一区二区久久久| 欧美二区乱c少妇| 久久国产精品99精品国产| 欧美电影在线观看完整版| 欧美在线亚洲一区| 欧美午夜无遮挡| 亚洲第一主播视频| 国产综合网站| 亚洲欧美卡通另类91av| 亚洲裸体俱乐部裸体舞表演av| 欧美一区二区精美| 亚洲午夜在线观看| 欧美精品三级| 亚洲第一天堂无码专区| 国内精品久久久久久久影视麻豆| 一区二区三区国产在线| 亚洲国产欧美在线| 久久久久欧美精品| 久久久久久久久久久久久女国产乱 | 欧美日韩理论| 亚洲第一精品夜夜躁人人躁| 国产午夜精品一区理论片飘花| 亚洲色图综合久久| 亚洲欧美第一页| 欧美特黄一级大片| 一区二区三区高清| 亚洲视频自拍偷拍| 欧美日韩午夜在线视频| 亚洲精品免费观看| 一区二区三区精品视频| 欧美精品一区二区蜜臀亚洲| 欧美高清不卡在线| 亚洲精品影院在线观看| 欧美激情91| 亚洲激精日韩激精欧美精品| 亚洲国产欧美一区二区三区同亚洲| 久久久噜噜噜久久狠狠50岁| 久久综合久久88| 伊人狠狠色丁香综合尤物| 久久精品91久久久久久再现| 久久久成人网| 伊人春色精品| 欧美激情视频网站| 夜夜爽夜夜爽精品视频| 亚洲永久免费| 国产日韩精品一区观看| 久久久午夜精品| 欧美激情欧美狂野欧美精品| 亚洲激情电影在线| 欧美日韩国产综合视频在线观看中文| 99re6这里只有精品| 欧美一区=区| 激情久久久久久久| 欧美jjzz| 亚洲一区高清| 免费在线播放第一区高清av| 亚洲人成人99网站| 国产精品福利在线观看网址| 亚洲欧美国产另类| 欧美大色视频| 亚洲一区在线免费观看| 国产有码一区二区| 欧美精品免费播放| 午夜一区在线| 亚洲国产一区二区三区a毛片| 亚洲一区免费网站| 激情欧美国产欧美| 欧美日本一道本| 欧美亚洲专区| 亚洲精品在线二区| 久久在精品线影院精品国产| 日韩视频永久免费| 国产免费一区二区三区香蕉精| 久久久久国色av免费观看性色| 亚洲久久一区| 美女国内精品自产拍在线播放| 一本色道久久99精品综合 | 欧美日韩成人一区二区三区| 欧美一区二区三区男人的天堂| 亚洲风情亚aⅴ在线发布| 欧美一区二区三区成人| 日韩视频永久免费观看| 国语自产精品视频在线看抢先版结局 | 久久不见久久见免费视频1| 亚洲精品一区二区三| 免费观看不卡av| 欧美在线播放视频| 亚洲天堂久久| 亚洲看片免费| 樱桃成人精品视频在线播放| 欧美日韩一区二区国产| 久久中文字幕导航| 久久精品国产一区二区三| 亚洲一区在线观看视频| 亚洲黄一区二区| 亚洲第一区在线观看| 久久久久久午夜| 久久激情视频免费观看| 亚洲在线观看视频| 亚洲天天影视| 亚洲天堂av电影| 日韩亚洲欧美成人一区| 91久久一区二区| 亚洲国产一区二区三区在线播| 影音欧美亚洲| 亚洲电影专区| 在线观看成人网| 在线欧美电影| 亚洲国产精品激情在线观看| 激情av一区| 亚洲国产1区| 91久久国产精品91久久性色| 激情欧美日韩| 在线精品福利| 亚洲激情视频在线播放| 亚洲欧洲免费视频| 一区二区黄色| 亚洲欧美韩国| 久久精品国产成人| 久久久人成影片一区二区三区| 久久九九全国免费精品观看| 久久福利电影| 欧美h视频在线| 亚洲三级视频| 在线视频亚洲一区| 亚洲综合视频在线| 久久久www成人免费毛片麻豆| 欧美一区二区日韩| 久久久久**毛片大全| 久久综合一区二区| 欧美日韩高清在线播放| 国产精品久久久久久久久果冻传媒 | 激情成人亚洲| 亚洲国产综合在线| 亚洲综合色在线| 久久精品夜色噜噜亚洲a∨ | 免费一级欧美在线大片| 亚洲国产精品女人久久久| 夜夜嗨av一区二区三区四季av| 亚洲自拍偷拍视频| 玖玖视频精品| 国产精品国产a级| 怡红院av一区二区三区| 一区二区三区四区蜜桃| 欧美专区一区二区三区| 欧美激情亚洲综合一区| 亚洲视频你懂的| 久久久久久久波多野高潮日日 | 午夜免费日韩视频| 农村妇女精品| 国产麻豆精品theporn| 亚洲国产精品久久| 午夜精品福利一区二区三区av| 欧美 日韩 国产一区二区在线视频 | 噜噜噜91成人网| 一本久道久久综合狠狠爱| 久久国产精彩视频| 欧美日韩在线观看一区二区| 国产综合网站| 亚洲男人的天堂在线| 欧美激情一区二区三区四区| 国产精品99久久久久久久vr| 噜噜噜久久亚洲精品国产品小说| 欧美性猛交一区二区三区精品| 亚洲国产美女精品久久久久∴| 欧美一级播放| 一本大道久久a久久精品综合| 久久亚洲春色中文字幕| 国产一区二区三区直播精品电影 | 狠狠干成人综合网|