MobiLink Synchronization Reference
Synchronization Events
Defines a cursor that the MobiLink synchronization server uses to insert, update, or delete rows during processing of the upload stream.
Use statement-based events for uploadsThis script has been deprecated. Use the statement-based events upload_delete, upload_insert, and upload_update instead of the upload_cursor event to process the upload stream. Support for the upload_cursor event is likely to be removed from future releases. |
Item | Parameter |
---|---|
1 | primary key 1 |
2 | primary key 2 |
... | ... |
None.
The MobiLink synchronization server opens a cursor with which to insert, update, or delete rows in the consolidated database based on rows uploaded from a client application. This script should contain a suitable SELECT statement or call a stored procedure that contains a suitable SELECT statement.
The parameters are the values of each column included in the primary key of the corresponding client table. You must use these in a WHERE clause, so that the synchronization can identify a unique row based on these values. The type and order of the parameters is as defined in the example_upload_cursor script. This order is the same as that in the corresponding table definition in the remote database, which in turn may have been copied from your reference database.
You can have one upload_cursor script for each table in the remote database.
For Java and .NET applications, this script must return valid SQL.
Writing scripts to upload rows
The following SELECT statement defines the upload cursor in the CustDB sample application.
SELECT cust_id, cust_name FROM ULCustomer WHERE cust_id = ?
The primary key of the ULCustomer table in the CustDB sample application is the column cust_id. If the corresponding table in the consolidated database is, instead, named Customer, then change the above statement as follows.
SELECT cust_id, cust_name FROM Customer WHERE cust_id = ?
The following stored procedure call registers a Java method called uploadCursor as the script for the upload_cursor cursor event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.
call ml_add_java_table_script( 'ver1', 'table1', 'upload_cursor', 'ExamplePackage.ExampleClass.uploadCursor' )
Following is the sample Java method uploadCursor. It dynamically generates an upload cursor.
public String uploadCursor() { return( getUploadCursor( _curTable ) ); }
The following C# example deletes the contents of a temporary table. It then returns SQL that causes rows to be uploaded into the temporary table.
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 = ?" ); }