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

end_upload table event

Processes statements related to a specific table just after the MobiLink server concludes processing of uploaded inserts, updates, and deletions.


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 Description Order (deprecated for SQL)
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable


VARCHAR(128). The MobiLink user name.



VARCHAR(128). The table name.


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



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

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

SQL example

The following call to a MobiLink system procedure assigns the end_upload event to a stored procedure called ULCustomerIDPool_maintain.

CALL ml_add_table_script(
   '{ CALL ULCustomerIDPool_maintain( {ml s.username} ) }' )

The following SQL statements create the ULCustomerIDPool_maintain stored procedure. This procedure inserts new primary keys, to replace the keys used by the rows just uploaded, into a primary key pool that gets downloaded to the remote database later in the same synchronization.

CREATE PROCEDURE ULCustomerIDPool_maintain ( IN syncuser_id INTEGER )
    DECLARE pool_count INTEGER;

    -- Determine how many ids to add to the pool
    SELECT COUNT(*) INTO pool_count
        FROM ULCustomerIDPool WHERE pool_emp_id = syncuser_id;

    -- Top up the pool with new ids
    WHILE pool_count < 20 LOOP
        INSERT INTO ULCustomerIDPool ( pool_emp_id ) VALUES ( syncuser_id );
        SET pool_count = pool_count + 1;
Java example

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

CALL ml_add_java_table_script(
   'ExamplePackage.ExampleClass.endUploadTable' )

The following is the sample Java method endUploadTable. It generates a delete for a table with a name related to the passed-in table name. This syntax is for SQL Anywhere consolidated databases.

package ExamplePackage;
public class ExampleClass {
  String _curUser = null; 
public void endUploadTable(
  String user,
  String table ) {
  return( "DELETE from '" + table + "_temp'" ); 
.NET example

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

CALL ml_add_dnet_table_script(

The following .NET example moves rows inserted into a temporary table into the table passed into the script.

using Sap.MobiLink.Script;
namespace TestScripts 
    public class Test 
	DBConnection	_curConn = null;
	public Test( DBConnectionContext cc ) 
	    _curConn = cc.GetConnection();
	public void EndUpload( string user, string table ) 
	    DBCommand stmt = _curConn.CreateCommand();
	    // Move the uploaded rows to the destination table.
	    stmt.CommandText = "INSERT INTO "
		    + table
		    + " SELECT * FROM dnet_ul_temp";