The script can be used to modify the last download time for the next synchronization.
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.
In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated and it is recommended that you use named parameters. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you want to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.
Parameter name for SQL scripts | Description | Order (deprecated for SQL) |
---|---|---|
s.next _last_download |
TIMESTAMP. This is an INOUT parameter. The MobiLink server generates this value immediately after the upload is committed. |
1 |
s.last_download |
TIMESTAMP. This is the last download time for the current synchronization. |
2 |
s.remote_id | VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. | Not applicable |
s.username |
VARCHAR(128). The MobiLink user name. |
3 |
None.
This script allows you to change the next_last_download timestamp, which effectively changes the last_download timestamp for the next synchronization. This allows you to reset the next synchronization without affecting the current synchronization. During normal synchronization, the next_last_download is later than than, but also sometimes equal to, the last_download time.
SQL scripts for the modify_next_last_download_timestamp event must be implemented as stored procedures. The MobiLink server passes in the next_last_download timestamp as the first parameter to the stored procedure, and replaces the timestamp by the first value passed out by the stored procedure.
This script is executed in the download transaction, after downloading user tables, but the output value of your stored procedure should correspond to the beginning of the download transaction so that rows changed during the download transaction are downloaded on the next synchronization.
The following example shows one application of this script. Create a stored procedure. The following syntax is for a SQL Anywhere consolidated database:
CREATE PROCEDURE ModifyNextDownloadTimestamp( inout next_last_download TIMESTAMP , in last_download TIMESTAMP , in user_name VARCHAR(128) ) BEGIN SELECT dateadd(hour, -1, next_last_download ) INTO next_last_download END |
Install the script into your SQL Anywhere consolidated database:
CALL ml_add_connection_script( 'modify_ts_test', 'modify_next_last_download_timestamp', 'CALL ModifyNextDownloadTimestamp ( {ml s.next_last_download}, {ml s.last_download}, {ml s.username} )' ) |
The following call to a MobiLink system procedure registers a Java method called modifyNextDownloadTimestamp as the script for the modify_next_last_download_timestamp connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'modify_next_last_download_timestamp', 'ExamplePackage.ExampleClass.modifyNextDownloadTimestamp' ) |
The following is the sample Java method modifyNextDownloadTimestamp. It sets the download timestamp back an hour.
public String modifyNextDownloadTimestamp( Timestamp NextLastDownload, Timestamp lastDownload, String userName ) { NextLastDownload.setHours( NextLastDownload.getHours() -1 ); return( null ); } |
The following call to a MobiLink system procedure registers a .NET method called ModifyNextDownloadTimestamp as the script for the modify_next_last_download_timestamp connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'modify_next_last_download_timestamp', 'TestScripts.Test.ModifyNextDownloadTimestamp' ) |
The following is the sample .NET method ModifyNextDownloadTimestamp. It sets the download timestamp back an hour.
public string ModifyNextDownloadTimestamp ( ref DateTime next_last_download, DateTime last_download, string user_name ) { next_last_download = next_last_download.AddHours( -1 ); return ( null ); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |