The script can be used to customize the message text (error, warning, and information) that is sent to remote databases.
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.
In SQL scripts, you can specify event parameters by name or with a question mark, but 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 want 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 |
---|---|---|
s.error_message |
VARBINARY(1024). This is an INOUT parameter. |
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 |
INT. |
3 |
None.
SQL scripts for the modify_error_message event must be implemented as stored procedures.
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} )' ); |
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.
public String modifyLastErrorMessage( String lastErrorMessage, String userName, int errorCode ) { java.lang.System.out.println( "error message: " + lastErrorMessage ); java.lang.System.out.println( "error code: " + String.valueOf(errorCode) ); return( null ); } |
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.
public string ModifyLastErrorMessage ( string errorMessage, string userName, string errorCode ) { System.Console.WriteLine( "error message: " + errorMessage ); System.Console.WriteLine( "error code: " + errorCode ); return ( null ); } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |