OTL呼叫Oracle儲存過程

2021-06-21 01:51:35 字數 1067 閱讀 5396

otl很早前用過,今天寫東西要調儲存過程,程式寫完了,除錯死活通不過,折騰了一早晨。

最後才發現錯誤,這裡總結一下:

1、**寫的不規範。

有個引數後邊少寫了個「,」以至於總是抱錯。而單獨寫的測試例子就沒問題,後來一步一步跟蹤了後才發現。

2、呼叫格式

a、如果#define otl_ora9i // compile otl 4/oci8編譯

則過程呼叫採用:

begin

過程名(:引數1《型別,in|out|inout>,:引數2《型別,in|out|inout>,.....);

end;

的形式,和在pl/sql中一樣。

b、如果用#define otl_odbc // compile otl 4.0/odbc編譯

則用常規的形式:"

3、附文件中給出的測試**

// 建立儲存過程

/*create or replace procedure test(p1 in number, p2 in number, p3 out number) is

begin

p3 := p1 + p2;

end test;

*///呼叫**

#include

using namespace std;

#include

#define otl_ora9i//otl_odbc // compile otl 4.0/odbc

#include

#pragma comment(lib,"oci.lib")

otl_connect db; // connect object

void stored_proc1(void)

// invoking stored procedure

catch(otl_exception& p)

db.logoff(); // disconnect from the data source

getchar();

return 0;}

OTL呼叫Oracle儲存過程

otl很早前用過,今天寫東西要調儲存過程,程式寫完了,除錯死活通不過,折騰了一早晨。最後才發現錯誤,這裡總結一下 1 寫的不規範。有個引數後邊少寫了個 以至於總是抱錯。而單獨寫的測試例子就沒問題,後來一步一步跟蹤了後才發現。2 呼叫格式 a 如果 define otl ora9i compile o...

OTL呼叫儲存過程和函式

otl簡單介紹 oracle 儲存函式 func test create or replace function func test a in integer,b in out integer,c out integer return integer isd integer begin c 10 b...

使用OTL呼叫Oracle的儲存函式

otl介紹 otl 是 oracle,odbc and db2 cli template library 的縮寫,是乙個c 操控關聯式資料庫的模板庫,最新版本4.0.104,參見 優點 a.跨平台 b.執行效率高,與c語言直接呼叫api相當 c.開發效率高,起碼比ado.net使用起來更簡單,更簡潔...