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

begin_download table event

Processes statements related to a specific table just before preparing the download 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, 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.last_table_download TIMESTAMP. The last download time for the table. 1
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. 2
s.table VARCHAR(128). The table 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

The MobiLink 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 download 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.

SQL example

The following call to the MobiLink system procedure ml_add_table_script calls the BeginTableDownload procedure. This syntax is for a SQL Anywhere 16 consolidated database.

CALL ml_add_table_script( 
   'version1', 
   'Leads', 
   'begin_download',
   'CALL BeginTableDownLoad( 
     {ml s.username},
     {ml s.table} )' );

The following SQL statements create the BeginTableDownload procedure. It records the download attempt in a table.

CREATE PROCEDURE BeginTableDownload( 
   MLUser varchar(128), 
   TableName varchar(128) )
BEGIN
  INSERT INTO DownloadAttempts ( MLUser, TableName, LastDownload );
END
Java example

The following call to a MobiLink system procedure registers a Java method called beginDownloadTable as the script for the begin_download table event when synchronizing the script version ver1.

CALL ml_add_java_table_script( 
  'ver1',
  'table1',
  'begin_download',
  'ExamplePackage.ExampleClass.beginDownloadTable'
 )

The following is the sample Java method beginDownloadTable. It prints a message to the MobiLink message log. (Printing a message to the MobiLink message log might be useful at development time but would slow down a production server.)

package ExamplePackage;
public class ExampleClass {
  String _curUser = null;
public void beginDownloadTable( 
  String user, 
  String table ) {
  java.lang.System.out.println("Beginning to process download for: " + table);
  }}
.NET example

The following call to a MobiLink system procedure 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.

CALL ml_add_dnet_table_script(
  'ver1', 
  'table1', 
  'begin_download',
  'TestScripts.Test.BeginTableDownload'
)

The following is the sample .NET method BeginTableDownload. It prints a message to the MobiLink message log. (Printing a message to the MobiLink message log might be useful at development time but would slow down a production server.)

namespace TestScripts {
public class Test {
  string _curUser = null;       
public void BeginTableDownload(
  string user,
  string table ) {  
  System.Console.WriteLine("Beginning to process download for: " + table);
  }}}