begin_synchronization connection event

Processes any statements at the time an application connects to the MobiLink server in preparation for 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

Default action

None.

Remarks

The MobiLink server executes this event immediately after an application preparing to synchronize has formed a connection with the MobiLink server. It is executed within a separate transaction before the upload transaction.

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

See also
SQL example

You may want to store the username value in a temporary table or variable if you want to reference that value many times in subsequent scripts.

CALL ml_add_connection_script ( 
  'version1', 
  'begin_synchronization', 
  'set @EmployeeID = {ml s.username}' );
Java example

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

CALL ml_add_java_connection_script( 
 'ver1',
 'begin_synchronization',
 'ExamplePackage.ExampleClass.beginSynchronizationConnection'
)

The following is the sample Java method beginSynchronizationConnection. It saves the name of the synchronizing user for later use.

public String beginSynchronizationConnection(
  String user ) {  
  _curUser = user;
  return ( null );
}
.NET example

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

CALL ml_add_dnet_connection_script( 'ver1',
  'begin_synchronization',
  'TestScripts.Test.BeginSync'
)

The following is the sample .NET method BeginSync. It saves the name of the synchronizing user for later use.

public string BeginSync( 
  string user ) { 
  _curUser = user;
  return ( null );
}