Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92216958
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Sybase

2008-04-10 20:56:11

来源:赛迪网    作者:puyu

例:通过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设置面板,修改相关参数,再运行,一切正常。

阅读(614) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~