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

modify_error_message connection event

The script can be used to customize the message text (error, warning, and information) that is sent to remote databases.

Parameters

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

VARBINARY(1024). This is an INOUT parameter, representing the error message.

1

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.

2

s.error_code

INTEGER. The MobiLink error code associated with the error_message.

3

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

None.

Remarks

This script gives you the ability to change the error_message into something the remote user and/or application can understand better than the original message.

SQL scripts for the modify_error_message event must be implemented as stored procedures.

SQL example

The following example downloads everything from one day ago, regardless of whether the databases were synchronized since then.

The following SQL statement creates the ModifyLastErrorMessage stored procedure:

CREATE PROCEDURE ModifyLastErrorMessage(
  inout error_message VARBINARY(1024),
  in username VARCHAR(128),
  in error_code INT )
BEGIN
  SELECT dateadd(day, -1, last_download_time )
  INTO last_download_time
END

The following call to a MobiLink system procedure assigns ModifyLastErrorMessage to the modify_error_message connection event for the script version modify_ts_test:

CALL ml_add_connection_script(
  'modify_ts_test',
  'modify_error_message',
  'CALL ModifyLastErrorMessage ( 
    {ml s.error_message}, 
    {ml s.username}, 
    {ml s.error_code} )' );
Java example

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

CALL ml_add_java_connection_script(
  'ver1',
  'modify_error_message',
  'ExamplePackage.ExampleClass.modifyLastErrorMessage' )

The following is the sample Java method modifyLastErrorMessage. It prints the current error message and error code.

package ExamplePackage; 
public class ExampleClass {
  String _curUser = null;
public void modifyLastErrorMessage(
  com.sap.ml.script.InOutString lastErrorMessage,
  String userName,
  int errorCode ) {  
  java.lang.System.out.println( "error message: " +
   lastErrorMessage );
  java.lang.System.out.println( "error code: " +
   String.valueOf(errorCode) );
  }}
.NET example

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

CALL ml_add_dnet_connection_script(
  'ver1',
  'modify_error_message',
  'TestScripts.Test.ModifyLastErrorMessage' )

The following is a sample .NET method ModifyLastErrorMessage. It prints the current error code and error message.

namespace TestScripts {
public class Test {
  string _curUser = null;
public void ModifyLastErrorMessage (
  ref string errorMessage,
  string userName,
  string errorCode  ) {
  System.Console.WriteLine( "error message: " + errorMessage );
  System.Console.WriteLine( "error code: " +  errorCode );
  }}}