MobiLink通过Oracle返回下载的数据流

王朝oracle·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

例:通过Sybase mobilink实现两个数据库之间数据同步(客户端与服务器),其中牵涉到数据的下载,在进行数据下载时,假如通过调用存储过程实现的下载流获取,那么实际操作中同步老是报错,原因如下:

环境描述如下:

中心数据库(服务器端):数据库为Oracle,mobilink服务器通过ODBC与数据库建立连接远程数据库(客户端):sybase ASA

客户端需要从服务端下载表A中指定条数的记录,由于业务需要,在下载过程中还需要对相关表格进行较为复杂设置,例如下载后需要将该记录的某列置为‘已下载’,从而避免其他客户端进行重复下载,因此在服务端使用存储过程进行下载流控制,从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} )}');

按照文档描述,进行相关设置后,进行同步,但是在同步进行中mobilink服务器报错,信息如下('EAPP_BARCODE_DOWNLOAD' 为存储过程名字):

错误: 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 状态 = HY000,本地错误代码 = 6550)

I. 05/17 20:05:20 <1.9> [1100139459]:

错误环境: 用户名: 1100139459 修改的用户名: 1100139459

事务: 下载 表名: ES_APP_BARCODEI. 05/17 20:05:20 <1.9>

[1100139459]: 脚本版本: BCGET 脚本: {call

EAPP_BARCODE_DOWNLOAD(?,?)} 错误环境结束

I. 05/17 20:05:20 <1.9> [1100139459]:

警告: [10010] 未定义任何错误处理脚本。

缺省的动作代码 (3000) 将决定错误行为。

I. 05/17 20:05:20 <1.9> [1100139459]:

download_cursor ES_APP_BARCODE(关闭)

从错误信息看来,是由于调用存储过程时所使用参数个数错误导致,后来经过查找发现:可能出现该原因是在ODBC设置中未勾选“Procedure Returns Results”所致,进入ODBC设置面板,修改相关参数,再运行,一切正常。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航