例:通過(guò)Sybase mobilink實(shí)現(xiàn)兩個(gè)數(shù)據(jù)庫(kù)之間數(shù)據(jù)同步(客戶端與服務(wù)器),其中牽涉到數(shù)據(jù)的下載,在進(jìn)行數(shù)據(jù)下載時(shí),假如通過(guò)調(diào)用存儲(chǔ)過(guò)程實(shí)現(xiàn)的下載流獲取,那么實(shí)際操作中同步老是報(bào)錯(cuò),原因如下:環(huán)境描述如下: 中心數(shù)據(jù)庫(kù)(服務(wù)器端):數(shù)據(jù)庫(kù)為Oracle,mobilink服務(wù)器通過(guò)ODBC與數(shù)據(jù)庫(kù)建立連接遠(yuǎn)程數(shù)據(jù)庫(kù)(客戶端):sybase ASA 客戶端需要從服務(wù)端下載表A中指定條數(shù)的記錄,由于業(yè)務(wù)需要,在下載過(guò)程中還需要對(duì)相關(guān)表格進(jìn)行較為復(fù)雜設(shè)置,例如下載后需要將該記錄的某列置為‘已下載’,從而避免其他客戶端進(jìn)行重復(fù)下載,因此在服務(wù)端使用存儲(chǔ)過(guò)程進(jìn)行下載流控制,從sybase文檔中得知:Oracle requires that a package be defined.
This package must contain a record type
for the result set, and a cursor type
that returns the record type.
Create or replace package SPInfo asType
SPRec is record ( pk integer,
col1 varchar(100), col2 varchar(20));
Type SPCursor is ref cursor return SPRec;
End SPInfo;
Next, Oracle requires a stored procedure
with the cursor type as the first parameter.
Note that the download_cursor script only
passes in two parameters, not three. For
stored procedures returning result sets
in Oracle, cursor types declared as parameters
in the stored procedure definition define
the strUCture of the result set, but do not
define a true parameter as such. In this
example, the stored procedure also adds
the script to the MobiLink system table.
Create or replace procedure
DownloadMyTable( v_spcursor IN
OUT SPInfo.SPCursor,v_last_dl_ts IN
DATE,v_user_name IN VARCHAR ) AsBegin
Open v_spcursor For select pk, col1,
col2 from MyTable where last_modified >
= v_last_dl_ts and employee = v_user_name;
End;CALL ml_add_table_script
( 'v1', 'MyTable', 'download_cursor',
'{CALL DownloadMyTable({ml s.last_table_download},
{ml s.username} )}');按照文檔描述,進(jìn)行相關(guān)設(shè)置后,進(jìn)行同步,但是在同步進(jìn)行中mobilink服務(wù)器報(bào)錯(cuò),信息如下('EAPP_BARCODE_DOWNLOAD' 為存儲(chǔ)過(guò)程名字):錯(cuò)誤: ODBC: [MERANT][ODBC Oracle driver]
[Oracle]ORA-06550: line 1, column 8:
PLS-00306: wrong number or types
of arguments in call to 'EAPP_BARCODE_DOWNLOAD'
ORA-06550: line 1, column 8:PL/SQL: Statement
ignored (ODBC 狀態(tài) = HY000,本地錯(cuò)誤代碼 = 6550)
I. 05/17 20:05:20 <1.9> [1100139459]:
錯(cuò)誤環(huán)境: 用戶名: 1100139459 修改的用戶名: 1100139459
事務(wù): 下載 表名: ES_APP_BARCODEI. 05/17 20:05:20 <1.9>
[1100139459]: 腳本版本: BCGET 腳本: {call
EAPP_BARCODE_DOWNLOAD(?,?)} 錯(cuò)誤環(huán)境結(jié)束
I. 05/17 20:05:20 <1.9> [1100139459]:
警告: [10010] 未定義任何錯(cuò)誤處理腳本。
缺省的動(dòng)作代碼 (3000) 將決定錯(cuò)誤行為。
I. 05/17 20:05:20 <1.9> [1100139459]:
download_cursor ES_APP_BARCODE(關(guān)閉)從錯(cuò)誤信息看來(lái),是由于調(diào)用存儲(chǔ)過(guò)程時(shí)所使用參數(shù)個(gè)數(shù)錯(cuò)誤導(dǎo)致,后來(lái)經(jīng)過(guò)查找發(fā)現(xiàn):可能出現(xiàn)該原因是在ODBC設(shè)置中未勾選“Procedure Returns Results”所致,進(jìn)入ODBC設(shè)置面板,修改相關(guān)參數(shù),再運(yùn)行,一切正常。