Contents Index end_upload connection event end_upload_deletes table event

MobiLink Synchronization Reference
  Synchronization Events

end_upload table event


Function 

Processes statements related to a specific table just after the MobiLink synchronization server concludes processing the stream of uploaded 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. You must use parameter 1 if you want to use parameter 2.

Item Parameter Description
1 ml_username VARCHAR(128)
2 table VARCHAR(128)
Default action 

None.

Description 

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

See also 

begin_upload table event

end_upload connection event

SQL example 

The event can be used to clean up anything that may still exist in the database after the upload processing is done for a particular table.

Call ml_add_table_script(
   'version1',
   'Leads',
   'end_upload',
   'DELETE FROM T_Leads');
Java example 

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

Following is the sample Java method endUploadTable. It generates a delete for a table with a name related to the passing-in table name.

public String endUploadTable(   String user,
String table)
{  return( "DELETE from '" + table + "_temp'" ); }
.NET example 

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

Following is the C# signature for the call EndTableUpload.

public void EndTableUpload(
   string user, string table )

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

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";
  stmt.ExecuteNonQuery();
  stmt.Close();
}

Contents Index end_upload connection event end_upload_deletes table event