upload_insert table event

Provides an event that the MobiLink server uses during processing of the upload to handle rows inserted into the remote database.

Parameters

Parameter name for SQL scripts

Order

r.pk-column-1 1
... ...
r.pk-column-N N

r.column-1

N+1

... ...

r.column-M

N+M

Default action

None.

Remarks

The statement based upload_insert script performs direct inserts of column values.

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

For Java and .NET applications, this script must return valid SQL.

See also
SQL example

This example handles inserts that were made on the Customer table in the remote database. The script inserts the values into a table named Customer in the consolidated database. The final column of the table identifies the Customer as active. The final column does not appear in the remote database.

CALL ml_add_table_script(
 'ver1',
 'Customer',
 'upload_insert',
 'INSERT INTO Customer( 
   cust_id, 
   name, 
   rep_id, 
   active )
  VALUES ( 
   {ml r.cust_id}, 
   {ml r.name}, 
   {ml r.rep_id}, 
   1 )' );
Java example

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

CALL ml_add_java_table_script(
  'ver1',
  'table1',
  'upload_insert',
  'ExamplePackage.ExampleClass.uploadInsertTable' )

The following is the sample Java method uploadInsertTable. It dynamically generates an INSERT statement. This syntax is for SQL Anywhere consolidated databases.

public String uploadInsertTable() {  
  return("INSERT INTO " + _curTable + getCols(_curTable)
    + " VALUES " + getQM(_curTable)); 
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called UploadInsert as the script for the upload_insert table event when synchronizing the script version ver1 and the table table1. This syntax is for SQL Anywhere consolidated databases.

CALL ml_add_dnet_table_script(
  'ver1',
  'table1',
  'upload_insert',
  'TestScripts.Test.UploadInsert'
)

The following is the sample .NET method UploadInsert. It returns an INSERT statement for the ULCustomer table.

public static string UploadInsert() {
   return("INSERT INTO ULCustomer( cust_id, cust_name ) VALUES ( {ml r.cust_id}, {ml r.cust_name} )");
 }