otl oracle存储日期,使用OTL调用Oracle的存储函数

436979

OTL介绍:OTL 是 Oracle, Odbc and DB2-CLI Template Library 的缩写,是一个C++操控关系数据库的模板库,最新版本4.0.104,参见http://otl.sourceforge.net/,下载地址http://otl.sourceforge.net/otlv4_h.zip。优点:a. 跨平台      b. 运行效率高,与C语言直接调用API相当      c. 开发效率高,起码比ADO.net使用起来更简单,更简洁      d. 部署容易,不需要ADO组件,不需要.net framework 等缺点:      a. 只有C++才可以使用她      b. 说明以及范例不足(暂时性的)总的说来,对于C++程序员而言,使用OTL操作关系数据库是最好的选择,其网站上有很多的范例,本人在这里对使用OTL调用Oracle的存储函数(存储函数比存储过程多个返回值)作一个示范,而其他的比如查询、更新、存储过程等就太简单了,直接看otl.sourceforge.net的范例 。Oracle 存储函数 TEST 代码:( a In Integer, b Out Integer, c in out Integer, d In Long ) Return Longisbegin    b := a;    c := 2 * c;    Return( '' );end;说明:Oracle中的long不是C/C++中的长整型,而是varchar_long,对应着OTL中的otl_long_string,这是一种很复杂的类型,本人就用它来举例。C++调用TEST的代码:#include #include //#define OTL_ORA9I // 使用这个宏就表示使用Oracle9i的API,而不是ODBC API#define OTL_ODBC    // 使用这个宏就表示使用通用的ODBC API#include "otlv4.h"using namespace std;void main( void ){    otl_connect::otl_initialize();    try {        otl_connect db;        db.rlogon( "Driver={Microsoft ODBC for Oracle};Server=ZZZ;Uid=XXX;Pwd=YYY;" );        // db.set_max_long_size(?); 如果varchar_long长度非常长,超过默认值的话,你需要这一句        otl_stream o( 1, "{ :E = call TEST(  :A,:B,:C,:D        o.set_commit(0);        int a = 1;        int b = 0;        int c = 2;        otl_long_string d( "abc", 0, 3 );        otl_long_string e;        o         o >> e >> b >> c;                cout         cout         cout         //db.commit();        db.logoff();    }    catch( otl_exception& p ) {        cerr                                                     }}说明:"{ :E = call TEST(  :A,:B,:C,:D"{ call :Name1 := function( Name2 }"也不是"{ call :Name1 \\:= function( Name2 }"而是"{ :Name1 = call function( Name2 }"这一点和otl.sourceforge.net上的说明不一样。

09-20 01:32

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OTL介绍: OTLOracle, Odbc and DB2-CLI Template Library 的缩写,是一个C++操控关系数据库的模板库,最新版本4.0.104,参见http://otl.sourceforge.net/ 优点:a. 跨平台 b. 运行效率高,与C语言直接调用API相当 c. 开发效率高,起码比ADO.net使用起来更简单,更简洁 d. 部署容易,不需要ADO组件,不需要.net framework 等 缺点: a. 只有C++才可以使用她 b. 说明以及范例不足(已附带了686个实例) This document describes the Oracle, ODBC and DB2-CLI Template Library, Version 4.0 (OTL 4.0). OTL 4.0 is a C++ library based on C++ templates. OTL 4.0 was designed as a combination of a C++ template framework and OTL-adapters. The framework is a generic implementation of the concept of OTL streams. The OTL-adapters are thin wrappers around the database APIs and are used as class type parameters to be passed into the template framework. OTL 4.0 covers the functionality of a full featured C++ database access library with just a handful of classes: otl_stream, otl_connect, otl_exception, otl_long_string, and several template PL/SQL (Oracle) table container classes, generated from the template framework and the OTL-adapters. The OTL code gets expanded into direct database API function calls, so it provides very decent performance (only 10-15% overhead, compared with the database APIs themselves) and reliability in multi-processor environments as well as traditional batch programs. OTL 4.0, being a template library, is highly portable since it is self-sufficient and compact enough. OTL 4.0 is ANSI C++ compliant (ANSI C++ typecasts, clean templatized code, etc.), tightly integrated with the Standard Template Library (STL) via STL-compliant stream iterators, and natively supports the STL std::string's in otl_stream's. OTL integrates with ACE, and supports ACE_TStrings. OTL 4.0 supports all versions of Oracle starting with 7.3 (natively via the corresponding version of the OCI), DB2 UDB LUW / zOS (natively via DB2 CLI), MS SQL Server 2005/2008 (natively via SNAC), Informix 11 (natively via Informix CLI), TimesTen 7 and higher (natively TimesTen CLI), SAP-MAX/DB (natively via SAP/DB CLI), ODBC 3.x as well as ODBC 2.5 (for legacy applications) compliant data sources in MS Windows, Linux/Unix/Mac OS X (via unixodbc and iODBC driver managers): Sybase, MySQL, PostgreSQL, EnterpriseDB, SQLite, MS ACCESS, Firebird, etc. The list of supported database back ends is growing. In the last few years, transition from the 32-bit platforms to the 64-bit platforms has occurred: OTL's source code is portable, and it support both 32-bit and 64-bit C++ compilers. Also, OTL supports UTF-8 and UTF-16 for Oracle, and UTF-16 for the rest of the database types, when the underlying database API / ODBC driver supports it.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值