mobilink通过oracle存储过程返回下载数据流问题

    最近, 正在做一个项目,该项目需通过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 as
Type 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 ) As
Begin
    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_BARCODE
I. 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设置面板,修改相关参数,再运行,一切OK!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值