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

寶杉的博客

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 寶杉 閱讀(2600) 評論(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

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            中文久久乱码一区二区| 亚洲一区二区三区免费观看| 免费成人性网站| 久热精品视频在线观看| 最新国产拍偷乱拍精品| 亚洲国产另类久久久精品极度| 久久综合福利| 日韩视频一区二区三区在线播放| 亚洲免费播放| 国产精品美女xx| 久久婷婷亚洲| 欧美激情小视频| 亚洲中午字幕| 久久久久成人精品| 在线视频亚洲欧美| 午夜精品一区二区三区电影天堂| 狠狠久久综合婷婷不卡| 亚洲电影免费在线| 国产精品日本精品| 欧美成人免费在线| 欧美视频精品在线| 久久久久久久精| 欧美精品日韩一区| 久久国产精品毛片| 欧美区在线观看| 欧美在线观看网站| 欧美精品大片| 久久国产日本精品| 欧美激情第二页| 亚久久调教视频| 欧美国产亚洲精品久久久8v| 亚洲欧美日韩一区在线| 久久综合电影| 欧美一区二区三区在线免费观看| 久久综合九色综合网站| 欧美一区二区在线免费播放| 欧美不卡视频一区| 欧美一区二区三区成人| 欧美国产日韩亚洲一区| 裸体素人女欧美日韩| 国产精品久久久久久久久久妞妞| 欧美激情久久久| 韩国视频理论视频久久| 亚洲在线观看免费视频| 日韩一级在线| 欧美不卡一卡二卡免费版| 久久久人成影片一区二区三区观看 | 国产日韩在线亚洲字幕中文| 亚洲精品乱码久久久久久黑人 | 国内精品亚洲| 亚洲免费在线视频一区 二区| 99国产精品自拍| 免费观看亚洲视频大全| 另类综合日韩欧美亚洲| 国产主播一区| 欧美在线电影| 久久久久国产精品厨房| 国产日韩在线播放| 亚洲欧美亚洲| 久久久av水蜜桃| 国产美女高潮久久白浆| 亚洲主播在线| 欧美一区二区三区免费视频| 国产精品视频不卡| 亚洲香蕉成视频在线观看 | 亚洲国产精品999| 久久国产乱子精品免费女| 欧美影院精品一区| 国产在线高清精品| 久久精品一本| 女同性一区二区三区人了人一 | 欧美日韩在线不卡一区| 亚洲国产精品t66y| 99国产精品国产精品毛片| 欧美精品色网| 亚洲天堂成人| 久久精品中文字幕一区二区三区 | 欧美激情视频一区二区三区在线播放 | 国产亚洲综合精品| 久久精品在线播放| 欧美电影免费观看高清完整版| 亚洲国产高潮在线观看| 欧美成人小视频| 中文国产一区| 久久人人爽国产| 最新日韩在线视频| 欧美日韩亚洲成人| 欧美在线国产| 欧美高清在线视频| 亚洲图片欧美日产| 国产午夜精品福利| 女生裸体视频一区二区三区| 一本色道精品久久一区二区三区 | 亚洲狼人精品一区二区三区| 欧美日韩免费高清一区色橹橹| 亚洲性视频网址| 免费在线亚洲欧美| 夜夜爽夜夜爽精品视频| 国产精品专区一| 欧美v亚洲v综合ⅴ国产v| 夜夜夜久久久| 米奇777在线欧美播放| 亚洲天堂av在线免费| 国产综合亚洲精品一区二| 欧美日韩福利在线观看| 欧美一区二区观看视频| 亚洲欧洲三级电影| 久久精品主播| 亚洲综合精品四区| 亚洲成人资源| 国产日韩在线播放| 欧美日韩一区二区视频在线观看| 久久福利电影| 亚洲午夜av在线| 亚洲人在线视频| 久久综合999| 午夜精品久久久久久久久久久久| 亚洲国产美女| 国产在线播放一区二区三区| 欧美色精品在线视频| 免费成人av在线看| 久久超碰97人人做人人爱| 亚洲午夜在线视频| 99日韩精品| 亚洲区中文字幕| 欧美国产综合视频| 久久一二三国产| 久久精品国产一区二区三区免费看| 一区二区三区蜜桃网| 在线观看日韩| 精品96久久久久久中文字幕无| 欧美性猛交xxxx免费看久久久 | 免费成人网www| 久久国产日本精品| 翔田千里一区二区| 亚洲欧美日韩精品久久久久| 99精品欧美一区| 亚洲三级视频在线观看| 免费一级欧美片在线播放| 久久精品一区| 久久青青草原一区二区| 久久久久高清| 久久一日本道色综合久久| 久久亚洲春色中文字幕久久久| 久久精品国产亚洲aⅴ| 久久精品三级| 美女黄网久久| 亚洲高清免费在线| 亚洲日本视频| 9人人澡人人爽人人精品| 一区二区欧美日韩视频| 亚洲天堂久久| 性色av一区二区三区在线观看 | 亚洲欧美日韩综合aⅴ视频| 亚洲主播在线| 久久精品国产一区二区电影| 久久亚洲私人国产精品va| 久久综合一区二区三区| 欧美激情精品久久久久久变态| 欧美激情亚洲精品| 国产精品久久久久久久久| 国产亚洲欧美另类中文| 极品日韩久久| 99精品欧美一区二区蜜桃免费| 亚洲手机视频| 久久人人97超碰精品888| 欧美激情一区二区久久久| 99re8这里有精品热视频免费| 亚洲色图在线视频| 欧美在线二区| 欧美区一区二区三区| 国产欧美日韩精品a在线观看| 又紧又大又爽精品一区二区| 日韩一区二区高清| 久久精品人人爽| 亚洲国产你懂的| 午夜精品福利在线观看| 欧美xx视频| 国产美女精品免费电影| 亚洲精品国产日韩| 欧美一区二区日韩| 亚洲国产视频一区| 午夜视频在线观看一区二区| 免费看黄裸体一级大秀欧美| 国产精品日韩在线观看| 亚洲精品系列| 久久精品免费| 亚洲精选一区二区| 久久久久一区二区三区| 欧美天堂亚洲电影院在线播放| 在线观看91精品国产麻豆| 亚洲午夜电影在线观看| 欧美大片国产精品| 午夜精品婷婷| 欧美三级第一页| 亚洲二区免费| 久久国产精品亚洲77777| 99视频在线观看一区三区| 久久在线视频在线| 国产专区欧美专区|