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

寶杉的博客

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  回復(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)用存儲(chǔ)過程,得到出參的例子,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
這個(gè)是OTL調(diào)sql, ODBC的,注意是
#define OTL_ODBC

而不是ORACLE的例子

因?yàn)閛tl + 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í)候,我是在流里不斷的輸入,但是如果其中的一條語句錯(cuò)誤,異常了,他是否會(huì)把緩存里面的所有清空刷新呢? 我懷疑這樣我入庫的時(shí)候,會(huì)少數(shù)據(jù)呢? 聯(lián)系我 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>
            欧美日韩午夜剧场| 欧美日韩视频专区在线播放| 国产日韩欧美精品| 亚洲在线视频免费观看| 91久久精品一区| 欧美日韩在线播放三区| 一本色道久久99精品综合| 欧美连裤袜在线视频| 亚洲一区影院| 欧美在线地址| 亚洲日本中文| 亚洲影院色无极综合| 黄色精品一区| 一本不卡影院| 国语自产在线不卡| 亚洲黄色影片| 国产视频精品xxxx| 亚洲国产精品传媒在线观看| 国产精品国产三级国产aⅴ浪潮 | 久久一区二区三区四区| 99热精品在线观看| 销魂美女一区二区三区视频在线| 在线观看欧美日韩国产| 99av国产精品欲麻豆| 国产一区二区精品| 99www免费人成精品| 极品尤物一区二区三区| 99国产一区| 亚洲国产精品一区在线观看不卡 | 久久久亚洲国产天美传媒修理工 | 销魂美女一区二区三区视频在线| 亚洲国产婷婷综合在线精品 | 亚洲精品视频在线播放| 国内精品久久久久影院优| 最近看过的日韩成人| 国产亚洲欧美一级| 在线综合亚洲| 日韩一级在线观看| 久久久久久久网| 欧美有码视频| 欧美午夜一区二区| 亚洲日本视频| 亚洲国产三级在线| 久久不射电影网| 欧美一区激情视频在线观看| 欧美日韩国产123区| 欧美黄色免费网站| 黄色精品免费| 久久精品人人做人人爽电影蜜月| 亚洲女同精品视频| 欧美日韩一区三区四区| 91久久嫩草影院一区二区| 亚洲激情小视频| 毛片av中文字幕一区二区| 久久久五月天| 黑人一区二区三区四区五区| 午夜在线精品偷拍| 久久激情婷婷| 国产一区久久久| 久久国产精品亚洲77777| 乱码第一页成人| 久久久精品国产一区二区三区| 国产精品视频精品| 亚洲视频视频在线| 欧美一级成年大片在线观看| 国产精品天天看| 午夜在线观看免费一区| 久久久久久久999精品视频| 国产午夜精品理论片a级大结局| 亚洲欧美在线一区| 久久婷婷麻豆| 亚洲国产老妈| 欧美激情精品久久久| 亚洲精品日本| 亚洲欧美激情精品一区二区| 国产精品老女人精品视频| 亚洲自拍偷拍视频| 久久久久久有精品国产| 亚洲国产一成人久久精品| 欧美成人免费全部观看天天性色| 亚洲国产精品专区久久| 亚洲视频网在线直播| 国产农村妇女精品一区二区| 久久精品91久久香蕉加勒比 | 亚洲一区亚洲二区| 国产自产在线视频一区| 久久综合久久88| 99视频精品全国免费| 久久精品二区| 99v久久综合狠狠综合久久| 国产精品久久久久三级| 久久精品视频va| 亚洲精品中文字幕在线| 久久er99精品| 亚洲精品在线免费| 国产伦理精品不卡| 欧美freesex交免费视频| 亚洲电影在线免费观看| 欧美日韩一区二区三| 亚洲欧美一级二级三级| 欧美激情中文不卡| 午夜一区二区三视频在线观看 | 国产精品高潮呻吟视频| 久久久久久噜噜噜久久久精品| 亚洲国产视频一区| 久久久久99| 亚洲少妇最新在线视频| 亚洲电影下载| 国产日韩1区| 欧美日韩国产黄| 老司机aⅴ在线精品导航| 亚洲私人影院| 91久久国产自产拍夜夜嗨| 久久精品一区蜜桃臀影院| 亚洲一区网站| 亚洲美女中文字幕| 精品999成人| 国产欧美日韩一级| 欧美日韩综合网| 欧美国产日本韩| 久久久久久久久久看片| 午夜在线视频观看日韩17c| 一区二区国产在线观看| 亚洲国产网站| 欧美77777| 另类激情亚洲| 久久久噜噜噜久久| 久久成人一区| 欧美在线一区二区| 亚洲欧美综合一区| 久久精品国产成人| 午夜精品久久久久久99热软件| 在线视频精品一区| 亚洲精品在线观看视频| 亚洲黄一区二区| 亚洲欧洲日产国产网站| 亚洲片国产一区一级在线观看| 免费观看国产成人| 欧美激情bt| 亚洲第一在线视频| 亚洲国产精品久久人人爱蜜臀 | 亚洲精一区二区三区| 91久久久在线| 亚洲精选国产| 中文国产一区| 香蕉久久夜色精品国产使用方法| 午夜在线播放视频欧美| 久久国产免费看| 久久亚洲精品一区| 欧美理论在线| 国产精品一区二区久久精品| 国产精品视频一区二区三区 | 国产精品国产精品| 国产小视频国产精品| 激情久久久久| 亚洲精品日本| 亚洲影视在线播放| 久久国产精品久久久久久电车| 久久综合九色综合网站| 欧美韩国日本一区| 妖精成人www高清在线观看| 亚洲一级二级| 另类天堂视频在线观看| 欧美区高清在线| 国产日产亚洲精品| 亚洲日本中文字幕| 亚洲自拍啪啪| 男女激情视频一区| 亚洲精品一区二区三区av| 亚洲欧美激情视频| 麻豆精品在线视频| 国产精品国产三级国产普通话蜜臀| 国产酒店精品激情| 亚洲欧洲日本国产| 香蕉久久久久久久av网站| 久久综合网hezyo| 日韩午夜三级在线| 久久国产乱子精品免费女| 欧美日韩国产综合久久| 亚洲欧洲日韩综合二区| 亚洲欧美怡红院| 欧美www在线| 狠狠爱www人成狠狠爱综合网| 一本久久综合亚洲鲁鲁| 久久免费国产| 亚洲校园激情| 欧美高清视频在线| 精品成人国产| 欧美一区二区三区视频| 亚洲国语精品自产拍在线观看| 午夜在线精品| 国产精品成人va在线观看| 亚洲欧洲一区| 久久人人爽国产| 亚洲专区在线| 国产精品久久久久高潮| av成人福利| 亚洲国产精彩中文乱码av在线播放| 亚洲综合视频1区| 国产精品成人播放|