modify_next_last_download_timestamp connection event

The script can be used to modify the last download time for the next synchronization.

Parameters

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, but 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

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 an IN parameter. This is the last download time for the current synchronization. It can be useful in avoiding duplication, by making sure you don't modify the next_last_download timestamp to be earlier than the last_download timestamp.

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

Default action

None.

Remarks

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.

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.

See also
SQL example

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 download_timestamp TIMESTAMP ,
  in last_download TIMESTAMP ,
  in user_name VARCHAR(128) )
  BEGIN
    SELECT dateadd(hour, -1, download_timestamp )
    INTO download_timestamp
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} )' )
Java example

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' )

Following is the sample Java method modifyNextDownloadTimestamp. It sets the download timestamp back an hour.

public String modifyNextDownloadTimestamp(
  Timestamp downloadTimestamp,
  Timestamp lastDownload,
  String userName ) {
  downloadTimestamp.setHours(
  downloadTimestamp.getHours() -1 );
  return( null ); 
}
.NET example

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' )

Following is the sample .NET method ModifyNextDownloadTimestamp. It sets the download timestamp back an hour.

public string ModifyNextDownloadTimestamp (
  DateTime download_timestamp,
  DateTime last_download,
  string user_name ) {
  download_timestamp = download_timestamp.AddHours( -1 );
  return ( null );
}