定义 MobiLink 同步服务器在上载流处理过程中使用的游标,该游标将用于插入、更新或删除行。
对上载使用基于语句的事件已不支持使用此脚本。使用基于语句的事件 upload_delete、upload_insert 和 upload_update 代替 upload_cursor 事件来处理上载流。将来的版本中很可能会删除对 upload_cursor 事件的支持。 |
| 项 | 参数 |
|---|---|
| 1 | primary key 1 |
| 2 | primary key 2 |
| ... | ... |
无。
MobiLink 同步服务器打开一个游标,该游标将用于在统一数据库中基于客户端应用程序上载的行进行插入、更新或删除。该脚本应包含适当的 SELECT 语句或调用包含适当的 SELECT 语句的存储过程。
参数为包含在相应客户端表的主键中的每一列的值。您必须在 WHERE 子句中使用这些值,以便同步过程能够根据这些值标识唯一的行。参数的类型和顺序与 example_upload_cursor 脚本中所定义的相同。此顺序与远程数据库相应表定义中的顺序相同,而该顺序又是从参考数据库中复制来的。
您可以为远程数据库的每个表编写一个 upload_cursor 脚本。
对于 Java 和 .NET 应用程序,此脚本必须返回有效的 SQL。
下面的 SELECT 语句定义了 CustDB 示例应用程序中的上载游标。
call ml_add_table_script( 'ver1', 'table1', 'upload_cursor', 'SELECT cust_id, cust_name FROM ULCustomer WHERE cust_id = ?')
CustDB 示例应用程序中 ULCustomer 表的主键是 cust_id 列。如果统一数据库的相应表名为 Customer,则上述语句可更改为:
SELECT cust_id, cust_name FROM Customer WHERE cust_id = ?
下面的存储过程调用在同步脚本版本 ver1 时将名为 uploadCursor 的 Java 方法注册为 upload_cursor 事件的脚本。
call ml_add_java_table_script( 'ver1', 'table1', 'upload_cursor', 'ExamplePackage.ExampleClass.uploadCursor' )
下面是示例 Java 方法 uploadCursor。它调用 getUploadCursor 来动态生成一个上载游标。
public String uploadCursor()
{ return( getUploadCursor( _curTable ) ); }下面的存储过程调用在同步脚本版本 ver1 时将名为 UploadCursor 的 .NET 方法注册为 upload_cursor 事件的脚本。
call ml_add_dnet_table_script( 'ver1', 'table1', 'upload_cursor', 'TestScripts.Test.UploadCursor' )
下面的 C# 示例删除临时表的内容。然后,它返回 SQL,该 SQL 使行上载到临时表中。
public string UploadCursor()
{
DBCommand stmt = curConn.CreateCommand();
stmt.CommandText = "DELETE FROM dnet_ul_temp";
stmt.ExecuteNonQuery();
stmt.Close();
return( "SELECT * FROM dnet_ul_temp WHERE pk = ?" );
}SQL Anywhere Studio 9.0.2
版权所有 © 1989–2005 Sybase, Inc. 部分版权所有 © 2001–2005 iAnywhere Solutions, Inc. 保留所有权利。