Contents Index begin_download_deletes table event begin_publication connection event

MobiLink Synchronization Reference
  Synchronization Events

begin_download_rows table event


Function 

Processes statements related to a specific table just before fetching a list of rows to be inserted or updated in the specified table in the remote database.

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. For example, you must use parameter 1 if you want to use parameter 2.

Item Parameter Description
1 last_download TIMESTAMP
2 ml_username VARCHAR (128)
3 table VARCHAR (128)
Default action 

None.

Description 

This event is executed immediately before fetching the stream of rows to be inserted or updated in the named table in the remote database.

You can have one begin_download_rows script for each table in the remote database.

The last_download timestamp is the value obtained from the consolidated database during the last successful synchronization immediately prior to the download phase. If the current user has never synchronized successfully, this value is set to 1900-01-01.

See also 

begin_download_deletes table event

end_download_deletes table event

SQL example 

You can use the begin_download_rows table event to flag rows that you no longer want to download for this table. The following example archives sales leads that are over seven days old.

call ml_add_table_script( 'version1', 'Leads',
  'begin_download_rows',
  'call BeginDownloadRows (?, ?, ?)' );
create procedure BeginDownloadRows (
  LastDownload timestamp, MLUser varchar(128),
  TableName varchar(128) )
begin
  execute immediate 'update ' || TableName ||
  ' set download_flag = 0 where
  days(creation_time, CURRENT DATE) > 7 and Owner = '
  || MLUser;
end;
Java example 

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

call ml_add_java_table_script(
   'ver1',
   'table1',
   'begin_download_rows',
   'ExamplePackage.ExampleClass.beginDownloadRows' )

Following is the sample Java method beginDownloadRows. It generates an UPDATE statement using the table and user. MobiLink will execute this SQL statement.

public String beginDownloadRows( Timestamp ts,
String user, String table )
{  return( "update " + table + " set download_flag = 0 "
   + " where days(creation_time, CURRENT DATE) > 7 " +
   " and Owner = '" + user + "'" ); }
.NET example 

The following stored procedure call registers a .NET method called BeginDownloadRows as the script for the begin_download_rows table event when synchronizing the script version ver1 and the table table1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_dnet_table_script(
  'ver1', 'table1', 'begin_download_rows',
  'TestScripts.Test.BeginDownloadRows'
)

Following is the C# signature for the call BeginDownloadRows.

public void BeginDownloadRows(
  DateTime timestamp,
  string user,
  string table )

Contents Index begin_download_deletes table event begin_publication connection event