The script can be used to modify the last download time for the current 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.last_download |
TIMESTAMP. The earliest last download time for any synchronized table. This is an INOUT parameter. |
1 |
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. |
2 |
None.
Use this script when you want to modify the last_download timestamp for the current synchronization. If this script is defined, the MobiLink server uses the modified last_download timestamp as the last_download timestamp passed to the download scripts. A typical use of this script is to recover from losing data on the remote; you can reset the last_download timestamp to an early time such as 1900-01-01 00:00 so that the next synchronization downloads all the data. Also, when updates to consolidated tables can be time-stamped with times earlier than the time of the actual update, for example via DBMS replication, this script lets you adjust the last download time to avoid missing these updates on download.
SQL scripts for the modify_last_download_timestamp event must be implemented as stored procedures.
This script is executed just before the prepare_for_download script, in the same transaction.
The following SQL statement creates a stored procedure. The following syntax is for Oracle consolidated databases:
CREATE PROCEDURE ModifyDownloadTimestamp( download_timestamp OUT DATE, user_name IN VARCHAR ) AS BEGIN -- N is the maximum replication latency in the consolidated cluster download_timestamp := download_timestamp - N; END; |
The following syntax is for SQL Anywhere, Adaptive Server Enterprise, and SQL Server consolidated databases:
CREATE PROCEDURE ModifyDownloadTimestamp @download_timestamp DATETIME OUTPUT, @user_name VARCHAR( 128 ) AS BEGIN -- N is the maximum replication latency in consolidated cluster SELECT @download_timestamp = @download_timestamp - N END |
The following call to a MobiLink system procedure assigns the ModifyDownloadTimestamp stored procedure to the modify_last_download_timestamp event. The following syntax is for a SQL Anywhere consolidated database:
CALL ml_add_connection_script( 'my_version', 'modify_last_download_timestamp', '{CALL ModifyDownloadTimestamp( {ml s.last_download}, {ml s.username} ) }' ) |
The following call to a MobiLink system procedure registers a Java method called modifyLastDownloadTimestamp as the script for the modify_last_download_timestamp connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'modify_last_download_timestamp', 'ExamplePackage.ExampleClass.modifyLastDownloadTimestamp' ) |
The following is the sample Java method modifyLastDownloadTimestamp. It prints the current and new timestamp and modifies the timestamp that is passed in.
public String modifyLastDownloadTimestamp( Timestamp lastDownloadTime, String userName ) { java.lang.System.out.println( "old date: " + lastDownloadTime.toString() ); lastDownloadTime.setDate( lastDownloadTime.getDate() -1 ); java.lang.System.out.println( "new date: " + lastDownloadTime.toString() ); return( null ); } |
The following call to a MobiLink system procedure registers a .NET method called ModifyLastDownloadTimestamp as the script for the modify_last_download_timestamp connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'modify_last_download_timestamp', 'TestScripts.Test.ModifyLastDownloadTimestamp' ) |
The following is the sample .NET method ModifyLastDownloadTimestamp.
public string ModifyLastDownloadTimestamp( ref DateTime lastDownloadTime, string userName ) { System.Console.WriteLine( "old date: " + last_download_time.ToString() ); last_download_time = DateTime::Now; System.Console.WriteLine( "new date: " + last_download_time.ToString() ); return( null ); } |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |