Processes any statements just after the MobiLink server concludes processing uploaded inserts, updates, and deletes.
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.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.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 |
None.
The MobiLink server executes this script as the last step in the processing of uploaded information. Upload information is processed in a single transaction. The execution of this script is the last action in this transaction before statistical scripts.
The following SQL Anywhere SQL script calls the EndUpload stored procedure.
CALL ml_add_connection_script( 'ver1', 'end_upload', 'CALL EndUpload({ml s.username});' )
The following call to a MobiLink system procedure registers a Java method called endUploadConnection as the script for the end_upload connection event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'end_upload', 'ExamplePackage.ExampleClass.endUploadConnection' )
The following is the sample Java method endUploadConnection. It calls a method to perform operations on the database.
public void endUploadConnection( String user ) { // Clean up new and old tables. Iterator two_iter = _tables_with_ops.iterator(); while( two_iter.hasNext() ) { TableInfo cur_table = (TableInfo)two_iter.next(); dumpTableOps( _sync_conn, cur_table ); } _tables_with_ops.clear(); }
The following call to a MobiLink system procedure registers a .NET method called EndUpload as the script for the end_upload connection event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'end_upload', 'TestScripts.Test.EndUpload' )
The following is the sample .NET method EndUpload.
using Sap.MobiLink.Script; namespace TestScripts { public class ExampleClass { DBConnectionContext _cc = null; ExampleClass( DBConnectionContext cc ) { _cc = cc; } public void EndUpload( string userName ) { DBConnection conn = _cc.GetConnection(); try { DBCommand cmd = conn.CreateCommand(); try { cmd.CommandText = "CALL EndUpload( ? )"; cmd.Prepare(); DBParameter parm = new DBParameter(); parm.DbType = SQLType.SQL_CHAR; parm.Value = userName; cmd.Parameters.Add( parm ); cmd.ExecuteNonQuery(); } finally { cmd.Close(); } } finally { conn.Close(); } } } }