在使用otl的时候,otl_stream构造函数第一个参数buffer size的使用说明.
2007-09-06 13:30
417 查看
在http://otl.sourceforge.net/otl3_stream_class.htm 中对buffer size 的说明是:The buffer size is defined in logical rows to inserted into a table, selected from a table / view in one round-trip to the database (a.k.a. batch size, array size).
为此做了如下例子进行了测试.
代码如下:
// TestOCT.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <stdio.h>
//#define OTL_ORA10G
#define OTL_ORA9I // Compile OTL 4.0/OCI9i
#define OTL_ORA_UTF8 // Enable UTF8 OTL for OCI9i
#include <otlv4.h> // include the OTL 4.0 header file
#pragma comment(lib, "oci.lib")
otl_connect db; // connect object
#define CONNECTSTRING "test/12345@192.168.1.202"
char strSql[100] = { "select f1,f2 from test_tab"};
void insert()
{
otl_stream o(3,"INSERT INTO TEST_TAB(f1,f2)values(4,'b')",db);
}
void select()
{
otl_stream o(1,strSql,db);
int count = 0;
int myf1;
char myf2[30] = {""};
while(!o.eof())
{
o>>myf1;
o>>myf2;
count++;
cout<<"f1: "<<myf1<<", f2: "<<myf2<<", 当前行数: "<<count<<endl;
}
return ;
}
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try
{
db.rlogon(CONNECTSTRING); // connect to Oracle
otl_cursor::direct_exec(db,"drop table test_tab",otl_exception::disabled); // drop table
otl_cursor::direct_exec(db,"create table test_tab(f1 number, f2 nvarchar2(30))"); // create table
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p)
{ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
插入数据: otl_stream o(3,"INSERT INTO TEST_TAB(f1,f2)values(4,'b')",db);中otl_stream的构造函数的第一个 参数表示要插入的数据条数.
查询数据:otl_stream o(1,strSql,db);中otl_stream的构造函数的第一个参数表示查询到的数据从服务器传递到客户端的往返次数
执行上面的程序,得到的结果就是:
f1: 4, f2: b, 当前行数1
f1: 4, f2: b, 当前行数1
f1: 4, f2: b, 当前行数1
为此做了如下例子进行了测试.
代码如下:
// TestOCT.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <stdio.h>
//#define OTL_ORA10G
#define OTL_ORA9I // Compile OTL 4.0/OCI9i
#define OTL_ORA_UTF8 // Enable UTF8 OTL for OCI9i
#include <otlv4.h> // include the OTL 4.0 header file
#pragma comment(lib, "oci.lib")
otl_connect db; // connect object
#define CONNECTSTRING "test/12345@192.168.1.202"
char strSql[100] = { "select f1,f2 from test_tab"};
void insert()
{
otl_stream o(3,"INSERT INTO TEST_TAB(f1,f2)values(4,'b')",db);
}
void select()
{
otl_stream o(1,strSql,db);
int count = 0;
int myf1;
char myf2[30] = {""};
while(!o.eof())
{
o>>myf1;
o>>myf2;
count++;
cout<<"f1: "<<myf1<<", f2: "<<myf2<<", 当前行数: "<<count<<endl;
}
return ;
}
int main()
{
otl_connect::otl_initialize(); // initialize OCI environment
try
{
db.rlogon(CONNECTSTRING); // connect to Oracle
otl_cursor::direct_exec(db,"drop table test_tab",otl_exception::disabled); // drop table
otl_cursor::direct_exec(db,"create table test_tab(f1 number, f2 nvarchar2(30))"); // create table
insert(); // insert records into table
select(); // select records from table
}
catch(otl_exception& p)
{ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
db.logoff(); // disconnect from Oracle
return 0;
}
插入数据: otl_stream o(3,"INSERT INTO TEST_TAB(f1,f2)values(4,'b')",db);中otl_stream的构造函数的第一个 参数表示要插入的数据条数.
查询数据:otl_stream o(1,strSql,db);中otl_stream的构造函数的第一个参数表示查询到的数据从服务器传递到客户端的往返次数
执行上面的程序,得到的结果就是:
f1: 4, f2: b, 当前行数1
f1: 4, f2: b, 当前行数1
f1: 4, f2: b, 当前行数1
相关文章推荐
- 在使用otl的时候,otl_stream构造函数第一个参数buffer size的使用说明.
- otl_stream构造函数第一个参数buffer size的使用说明
- innodb_log_buffer_size和innodb_buffer_pool_size参数说明
- 怎样使用CWnd::SetTimer (第一个参数)
- uplodify使用参数说明
- 使用GP。tool 创建地图切片示例 参数说明
- linux find命令-exec参数使用说明
- 关于Adodb.Stream 的使用说明
- 使用max_dump_file_size 参数限制trc文件的大小
- NGUI的入门(插件参数说明及使用)
- window.open使用方法以及参数说明
- 第四周项目:三角形类的构造函数-(1)使用带参数构造函数
- 当call/apply传的第一个参数为null/undefined的时候js函数内执行的上下文对象是什么呢?
- JavaScript---window.open使用方法以及参数说明(完整版)
- shape 使用参数说明
- Adodb.Stream组件使用说明
- Powershell的格式化工具,FL\FT\AUTOSIZE参数的使用
- 使用Apache ab进行压力测试(参数说明)
- ffmpeg使用参数的中文说明
- WinCE中Build.exe工具的使用及其参数说明