MobiLink通过Oracle返回下载的数据流
文章作者 100test 发表时间 2007:12:01 14:50:29
来源 100Test.Com百考试题网
例:通过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 0select 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 ,