end_synchronization connection event

Processes any statements at the time an application disconnects from the MobiLink server upon completion of the synchronization process.

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.

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.synchronization_ok

INTEGER. This value is 1 for a successful synchronization and 0 for an unsuccessful synchronization.

2

Default action

None.

Remarks

The MobiLink server executes this script after synchronization is complete. If you are using blocking download acknowledgement, the script is executed after the MobiLink client has returned confirmation of receipt of the download.

This script is executed within a separate transaction after the download transaction.

The end_synchronization script is useful for maintaining statistics. This is because if the begin_synchronization script is called, the end_synchronization script is invoked even if there is an error or conflict, so while the upload transaction is rolled back, statistics are maintained.

See also
SQL example

The following SQL script calls a system procedure that records the end time of the synchronization attempt along with its success or failure status. This syntax is for SQL Anywhere consolidated databases.

CALL ml_add_connection_script(
 'ver1',
 'end_synchronization',
 'CALL RecordEndOfSyncAttempt(
   {ml s.username}, 
   {ml s.synchronization_ok} )' )
Java example

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

CALL ml_add_java_connection_script(
  'ver1',
  'end_synchronization',
  'ExamplePackage.ExampleClass.endSynchronizationConnection'
)

The following is the sample Java method endSynchronizationConnection. It uses a JDBC connection to execute an update. This syntax is for SQL Anywhere consolidated databases.

public String endSynchronizationConnection(
  String user ) 
  throws java.sql.SQLException {  
  execUpdate( _syncConn, 
   "UPDATE sync_count set count = count + 1 where user_id = '"
   + user + "' " );
  return ( null );
}
.NET example

The following call to a MobiLink system procedure registers a .NET method called EndSync as the script for the end_synchronization connection event when synchronizing the script version ver1.

CALL ml_add_dnet_connection_script(
  'ver1',
  'end_synchronization',
  'TestScripts.Test.EndSync'
)

The following is the sample .NET method EndSync. It updates the table sync_count. This syntax is for SQL Anywhere consolidated databases.

public string EndSync( 
  string user ) {
  return(
   "UPDATE sync_count set count = count + 1 where user_id = '"
   + user + "' ");
  return ( null );
}