摘要
動態SQL的第4種方法通過SQLDA(The SQL Descriptor Area)和oracle內部交換資料,可以執行直到程式運行時還不知道選擇表項或虛擬輸入宿主變數的個數和類型的SQL語句。
模組 oracle 的資料
| jmp_buf |
jmp_continue |
|
儲存程式斷點 |
| FILE* |
ORAin |
stdin |
預設輸入源 |
| FILE* |
ORAout |
stdout |
預設輸出源 |
| Int |
ORAresult |
0 |
錯誤標誌 |
| Char* |
Dml_commands[] |
略 |
資料操縱語句動詞表 |
| ORAquery |
Query |
|
封裝SQL執行過程 |
| ORAqueryBase |
pQuery |
&query |
為外部提供介面 |
與外部的介面
- ORAin,ORAout: 應用程式通過操縱這兩個變數改變oracle模組的輸入輸出源。
- ORAresult:oracle模組的執行結果(有待細分錯誤原因)。
- ORAconnect(user,password),ORAdisconnect():與資料庫建立與中斷連線,必須在執行任何SQL語句前建立串連。
- JMP_FOR_ERROR(label):如果oracle模組出現錯誤便轉到標號label處繼續執行,建立串連時出錯除外。
- ORAqueryBase* pQuery:見抽象類別ORAqueryBase的說明。
抽象類別 ORAqueryBase
| 返回資料類型 |
方法名稱 |
參數 |
描述 |
| int |
set |
int,int,int |
設定SQL描述區的大小 |
| int |
Alloc |
|
分配SQL描述區 |
| int |
get_statement |
|
從輸入源讀取SQL語句 |
| int |
set_statement] |
const char* |
以字串格式輸入SQL語句 |
| int |
execute |
|
執行準備好的SQL語句 |
| int |
free |
|
釋放SQL描述區 |
參考資料
《programmer''s Guide to the Oracle Precompilers》Release 1.8
《C++進階參考手冊》