Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

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, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. 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 are going 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

s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable
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. During normal synchronization, the next_last_download is later 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.

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

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

public void modifyNextDownloadTimestamp(
  Timestamp NextLastDownload,
  Timestamp lastDownload,
  String userName ) {
  NextLastDownload.setHours(
  NextLastDownload.getHours() -1 );
  }
.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' )

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

using System;
using System.Data;
namespace TestScripts {
public class Test {
    String _curUser = null;
public void ModifyNextDownloadTimestamp (
  ref DateTime next_last_download,
  DateTime last_download,
  string user_name ) {
  next_last_download = next_last_download.AddHours( -1 );
  }}}