Contents Index handle_odbc_error connection event modify_next_last_download_timestamp connection event

MobiLink Synchronization Reference
  Synchronization Events

modify_last_download_timestamp connection event


Function 

The script can be used to modify the last_download timestamp for the current 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.

Event parameters are optional only if no subsequent parameters are specified. You must use parameter 1 if you want to use parameter 2.

Item Parameter Description
1 last_download_timestamp TIMESTAMP. This is an INOUT parameter.
2 ml_username VARCHAR(128)
Default action 

None.

Description 

Use this script when you want to modify the last download timestamp for the current synchronization. If this script is defined, the MobiLink synchronization server calls this script and uses the modified last_download timestamp as the last_download timestamp passed to the download scripts.

SQL scripts for the modify_last_download_timestamp event must be implemented as stored procedures. The MobiLink synchronization server passes in the 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.

For example, if you defined the following download_cursor script, the MobiLink synchronization server would replace the ? with the value of the modified last download timestamp before executing the SELECT statement:

SELECT pk, c2, c3 FROM test WHERE last_modified > ?

This script is executed just before the prepare_for_download script, in the same transaction.

SQL example 

The following example downloads everything from one day ago, regardless of whether the databases were synchronized since then.

First, create a procedure for your Adaptive Server Anywhere consolidated database:

CREATE PROCEDURE ModifyLastDownloadTimestamp(
  inout last_download_time TIMESTAMP,
  in user_name VARCHAR(128) )
BEGIN
  SELECT dateadd(day, -1, last_download_time )
  INTO last_download_time
END

Second, install the script into your Adaptive Server Anywhere consolidated database:

call ml_add_connection_script(
  'modify_ts_test',
  'modify_last_download_timestamp',
  'call  ModifyLastDownloadTimestamp ( ?, ? )' )
Java example 

The following stored procedure call registers a Java method called modifyLastDownloadTimestamp as the script for the modify_last_download_timestamp connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_java_connection_script(
  'ver1',
  'modify_last_download_timestamp',
  'ExamplePackage.ExampleClass.modifyLastDownloadTimestamp' )

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 last_download_time,
     String user_name )
{  java.lang.System.out.println( "old date: " +
   last_download_time.toString() );
   last_download_time.setDate(
   last_download_time.getDate() -1 );
   java.lang.System.out.println( "new date: " +
   last_download_time.toString() );
   return( null ); }

Contents Index handle_odbc_error connection event modify_next_last_download_timestamp connection event