begin_upload table event

Processes statements related to a specific table just before the MobiLink server commences processing the stream of uploaded inserts, updates, and deletes.

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.

In SQL scripts, you can specify event parameters by name or with a question mark, but 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 want 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

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.

1

s.table

VARCHAR(128). The table name.

2

Default action

None.

Remarks

The MobiLink server executes this event as the first step in the processing of uploaded information. Upload information is processed in a separate transaction. The execution of this event is the first table-specific action in this transaction.

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

See also
SQL example

When uploading rows from a remote you may want to place the changes in an intermediate table and manually process changes yourself. You can populate a global temporary table in this event.

CALL ml_add_table_script( 
 'version1', 
 'Leads',
 'begin_upload', 
 'INSERT INTO T_Leads 
  SELECT * FROM Leads 
  WHERE Owner = @EmployeeID' )
Java example

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

CALL ml_add_java_table_script( 
  'ver1',
  'table1',
  'begin_upload',
  'ExamplePackage.ExampleClass.beginUploadTable'
 )

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

public String beginUploadTable( 
  String user, 
  String table ) {
  java.lang.System.out.println("Beginning to process upload for: " + table);
  return ( null );
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called BeginTableUpload as the script for the begin_upload table event when synchronizing the script version ver1 and the table table1.

CALL ml_add_dnet_table_script(
  'ver1', 
  'table1', 
  'begin_upload',
  'TestScripts.Test.BeginTableUpload'
)

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

public string BeginTableUpload(
  string user,
  string table ) {  
  System.Console.WriteLine("Beginning to process upload for: " + table);
  return ( null );
}