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

寶杉的博客

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 寶杉 閱讀(2592) 評論(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  回復(fù)  更多評論   

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  回復(fù)  更多評論   

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

以上是OTL中調(diào)用存儲過程,得到出參的例子,OTL說明書里是有的,但我也找了很久才找到的。網(wǎng)址是 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  回復(fù)  更多評論   

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

而不是ORACLE的例子

因為otl + oracle的例子網(wǎng)上非常多,
而otl + sqlServer的例子網(wǎng)上很少,

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

# re: OTL 4.0, OTL concept  回復(fù)  更多評論   

2008-10-14 19:18 by xiao_xiao
我在用到otl_stream時候,我是在流里不斷的輸入,但是如果其中的一條語句錯誤,異常了,他是否會把緩存里面的所有清空刷新呢? 我懷疑這樣我入庫的時候,會少數(shù)據(jù)呢? 聯(lián)系我 165621600

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲一区二区三区中文字幕| 美日韩精品免费| 欧美一区二区| 亚洲宅男天堂在线观看无病毒| 亚洲欧洲另类| 日韩亚洲欧美中文三级| 夜夜嗨av一区二区三区网站四季av| 亚洲精品免费一二三区| 99视频在线精品国自产拍免费观看| 亚洲精品视频在线| 亚洲网站视频| 久久国产日韩欧美| 美女视频黄 久久| 欧美福利电影网| 亚洲精品一区二区三区四区高清 | 国产精品午夜在线| 欧美日韩一区二区三区高清| 欧美三级欧美一级| 国产日韩欧美在线播放不卡| 一区一区视频| 一区二区三区日韩欧美精品| 午夜亚洲激情| 欧美成人69av| 亚洲精品国产拍免费91在线| 99成人免费视频| 性欧美18~19sex高清播放| 久久美女性网| 欧美日本不卡视频| 国产欧美日韩精品一区| 亚洲黄网站黄| 欧美一区二区黄| 亚洲电影在线看| 亚洲一级二级| 欧美成人午夜77777| 欧美大片免费久久精品三p | 欧美激情精品久久久久久| 一区二区三区四区精品| 麻豆9191精品国产| 一区二区高清| 欧美成人午夜剧场免费观看| 国产精品久久夜| 亚洲美女一区| 欧美ab在线视频| 亚久久调教视频| 欧美午夜三级| 99精品欧美一区二区蜜桃免费| 久久激情综合| 亚洲欧美国产精品桃花| 欧美日韩一区二区三区在线看| 欧美成人亚洲成人| 狠狠干狠狠久久| 欧美专区在线播放| 在线亚洲一区观看| 欧美日韩免费一区二区三区| 亚洲国产日韩欧美在线图片| 久久一区二区三区国产精品| 翔田千里一区二区| 国产亚洲电影| 久久天天躁狠狠躁夜夜av| 亚洲欧美日韩一区| 国产日本欧美视频| 久久精品欧美日韩| 欧美专区日韩专区| 伊人久久婷婷色综合98网| 蜜乳av另类精品一区二区| 久久久欧美精品sm网站| 在线免费观看日本欧美| 欧美激情一区二区三区在线视频观看 | 欧美亚洲免费在线| 亚洲一区二区三区高清不卡| 国产精品福利久久久| 亚洲午夜精品在线| 99国产精品久久久久久久成人热 | 亚洲视频导航| 一本一本久久a久久精品综合麻豆| 一本综合久久| 国产精品欧美久久| 亚洲影音一区| 最新成人在线| 欧美裸体一区二区三区| 亚洲精品社区| 亚洲精品乱码久久久久久蜜桃91| 快播亚洲色图| 亚洲国产裸拍裸体视频在线观看乱了| 蜜桃久久精品一区二区| 日韩午夜av在线| 国产精品一区=区| 欧美一区二区三区免费视频| 亚洲综合第一| 国产揄拍国内精品对白| 久久综合给合| 欧美成人精品在线观看| 在线亚洲一区观看| 日韩视频免费观看高清在线视频 | 欧美性天天影院| 亚洲天堂免费观看| 亚洲女性喷水在线观看一区| 国产欧美三级| 久久精品一区二区国产| 久久久久网址| 91久久综合亚洲鲁鲁五月天| 亚洲黄色性网站| 国产精品激情| 亚洲色图在线视频| 久久久综合免费视频| 亚洲日韩欧美视频| 一本色道久久加勒比88综合| 国产精品香蕉在线观看| 免费不卡中文字幕视频| 欧美日韩国产高清| 久久久99精品免费观看不卡| 免费一区二区三区| 亚洲午夜高清视频| 欧美一区二区三区四区视频| 亚洲国产免费| 亚洲一区二区三| 91久久香蕉国产日韩欧美9色| 亚洲午夜激情免费视频| 99国内精品久久| 欧美一区二区三区久久精品茉莉花| 在线国产日韩| 一区二区激情小说| 亚洲日韩视频| 欧美在线一级视频| 在线精品视频免费观看| 亚洲婷婷在线| 亚洲人人精品| 亚洲欧美日韩专区| 亚洲精品日韩在线| 欧美怡红院视频| 伊人男人综合视频网| 欧美在线视频网站| 99视频精品全国免费| 久久国产精品免费一区| 亚洲网址在线| 欧美激情亚洲自拍| 久久天天狠狠| 国产视频一区欧美| 欧美伊人久久| 亚洲一区激情| 欧美人与性动交α欧美精品济南到| 久久久亚洲一区| 国产伦理一区| 亚洲一本视频| 亚洲清纯自拍| 欧美日韩综合一区| 99精品视频网| 一区二区三区.www| 欧美精品在线播放| 亚洲大片一区二区三区| 国产精品久久久久77777| 亚洲欧美日韩天堂| 欧美一区二区在线| 国产精品大片wwwwww| 正在播放亚洲一区| 亚洲性线免费观看视频成熟| 欧美伦理视频网站| 午夜宅男久久久| 欧美在线视频日韩| 国产亚洲综合精品| 欧美一级久久久久久久大片| 性欧美18~19sex高清播放| 国产精品久久一卡二卡| 午夜精品久久久久久久99水蜜桃| 亚洲欧洲日韩在线| 国产精品免费观看视频| 亚洲午夜一区二区| 久久久久久亚洲精品不卡4k岛国| 欧美亚一区二区| 亚洲午夜激情网站| 久久精品亚洲一区二区三区浴池| 欧美日韩一二三四五区| 西瓜成人精品人成网站| 久久综合九色99| 亚洲日本中文字幕免费在线不卡| 欧美日韩国产区| 亚洲嫩草精品久久| 亚洲精品一区二区网址| 午夜伦欧美伦电影理论片| 欧美色视频日本高清在线观看| 亚洲一区二区三区免费视频| 久久国产精品网站| 亚洲电影自拍| 国产视频一区二区在线观看| 久久综合激情| 一本色道久久综合狠狠躁的推荐| 久久精品噜噜噜成人av农村| 亚洲福利视频网| 六月天综合网| 亚洲一区二区三区涩| 米奇777超碰欧美日韩亚洲| 午夜精品久久久久久久蜜桃app| 一本久道久久综合中文字幕| 麻豆精品91| 久久综合伊人77777| 在线看视频不卡| 欧美日韩精品福利| 欧美一区2区视频在线观看| 一本色道久久精品| 欧美激情精品久久久久久大尺度|