Contents Index begin_download connection event begin_download_deletes table event

MobiLink Synchronization Reference
  Synchronization Events

begin_download table event


Function 

Provides a location to process statements related to a specific table just before preparing the download stream of inserts, updates, and deletions.

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 

The MobiLink synchronization server executes this event as the first step in preparing download information for a specific table. The download information is prepared in its own transaction. The execution of this event is the first table-specific action in the transaction.

You can have one begin_download script for each table in the remote database. The script is only invoked when that table is synchronized.

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 

end_download table event

SQL example 

The following example can be used on an Adaptive Server Anywhere 9 database. The first chunk of code calls the ml_add_table_script, and the second creates a BeginTableDownload procedure.

call ml_add_table_script( 
   'version1', 
   'Leads', 
   'begin_download',
   'call BeginTableDownLoad( ?, ?, ? ) );
create procedure BeginTableDownload( 
   LastDownload timestamp, 
   MLUser varchar(128), 
   TableName varchar(128) )
begin
  execute immediate 'update ' || TableName ||
' set last_download_check = CURRENT TIMESTAMP
  where Owner = ' ||MLUser;
end
Java example 

The following stored procedure call registers a Java method called beginDownloadTable as the script for the begin_download 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',
   'ExamplePackage.ExampleClass.beginDownloadTable' )

Following is the sample Java method beginDownloadTable. It saves the name of the current table for use in a later member function call.

public String beginDownloadTable( 
   Timestamp ts,
   String user, 
   String table )
{  _curTable = table;
   return( null ); }
.NET example 

The following stored procedure call registers a .NET method called BeginTableDownload as the script for the begin_download 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',
  'TestScripts.Test.BeginTableDownload'
)

Following is the C# signature for the call BeginTableDownload.

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

Contents Index begin_download connection event begin_download_deletes table event