MobiLink Synchronization Reference
Synchronization Events
Processes statements related to a specific table just before fetching a list of rows to be deleted from the specified table in the remote database.
In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.
Event parameters are optional only if no subsequent parameters are specified. For example, you must use parameter 1 if you want to use parameter 2.
Item | Parameter | Description |
---|---|---|
1 | last_download | TIMESTAMP |
2 | ml_username | VARCHAR (128) |
3 | table | VARCHAR (128) |
None.
This event is executed immediately before fetching a list of rows to be deleted from the named table in the remote database.
You can have one begin_download_deletes script for each table in the remote database.
The last_download timestamp is the value obtained from the consolidated database during the last successful synchronization immediately prior to the download phase. If the current user has never synchronized successfully, this value is set to 1900-01-01.
begin_download_rows table event
To minimize the amount of data on remotes, you can use this event to flag data that will be deleted when the download_delete_cursor is executed. The following example flags for deletion sales leads from the remote device that are over 10 weeks old. The example can be used on an Adaptive Server Anywhere 9 database. The code calls the ml_add_table_script, and then creates a beginDownloadDeletes procedure.
call ml_add_table_script ( 'version1', 'Leads', 'begin_download_deletes', 'call BeginDownloadDeletes (?, ?, ?)' ); create procedure BeginDownloadDeletes( LastDownload timestamp, MLUser varchar(128), TableName varchar(128) ) begin execute immediate 'update ' || TableName || ' set delete_flag = 1 where days(creation_time, CURRENT DATE) > 70 and Owner = ' || MLUser; end;
The following stored procedure call registers a Java method called beginDownloadDeletes as the script for the begin_download_deletes table event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.
call ml_add_java_table_script( 'ver1', 'table1', 'begin_download_deletes', 'ExamplePackage.ExampleClass.beginDownloadDeletes' )
Following is the sample Java method beginDownloadDeletes. It saves the name of the current table for use in a later member function call.
public String beginDownloadDeletes( Timestamp ts, String user, String table ) { _curTable = table; return( null ); }
The following stored procedure call registers a .NET method called BeginDownloadDeletes as the script for the begin_download_deletes table event when synchronizing the script version ver1 and the table table1. This syntax is for Adaptive Server Anywhere consolidated databases.
call ml_add_dnet_table_script( 'ver1', 'table1', 'begin_download_deletes', 'TestScripts.Test.BeginDownloadDeletes' )
Following is the C# signature for the call BeginDownloadDeletes.
public void BeginDownloadDeletes( DateTime timestamp, string user, string table )