MobiLink Synchronization Reference
Synchronization Events
Allows you to log errors and to record the actions selected by the handle_error script.
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.
Event parameters are optional only if no subsequent parameters are specified. For example, you must use parameter 1 if you want to use parameter 2.
Item | Parameter | Description |
---|---|---|
1 | action_code | INTEGER. This parameter is mandatory. |
2 | error_code | INTEGER. This parameter is optional if none of the following parameters are specified. |
3 | error_message | TEXT. This parameter is optional if none of the following parameters are specified. |
4 | ml_username | VARCHAR(128). This parameter is optional if none of the following parameters are specified. |
5 | table | VARCHAR(128). This parameter is optional. |
None.
This script allows you to log errors and to record the actions selected by the handle_error script. This script is executed after the handle_error event, whether or not a handle_error script is defined. It is always executed in its own transaction, on a different database connection than the synchronization connection (the administrative/information connection).
The error code and error message allow you to identify the nature of the error. The action code value is returned by the last call to an error handling script for the SQL operation that caused the current error.
If the error happened as part of synchronization, the user name is supplied. Otherwise, this value is NULL.
If the error happened while manipulating a particular table, the table name is supplied. Otherwise, this value is NULL. The table name is the name of a table in the remote database. This name may or may not have a direct counterpart in the consolidated database, depending on the design of the synchronization system.
handle_odbc_error connection event
report_odbc_error connection event
The following example works with an Adaptive Server Anywhere consolidated database. It inserts a row into a table used to record synchronization errors.
call ml_add_connection_script( 'ver1', 'report_error', 'insert into sync_error( action_code, error_code, error_message, user_name, table_name ) values( ?, ?, ?, ?, ? )' )
The following stored procedure call registers a Java method called reportError as the script for the report_error connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.
call ml_add_java_connection_script( 'ver1', 'report_error, 'ExamplePackage.ExampleClass.reportError' )
Following is the sample Java method reportError. It logs the error to a table using the JDBC connection provided by MobiLink. It also sets the action code.
public String reportError( ianywhere.ml.script.InOutInteger actionCode, int errorCode, String errorMessage, String user, String table ) throws java.sql.SQLException { // insert error information in a table JDBCLogError( _syncConn, errorCode, errorMessage, user, table ); actionCode.setValue( getActionCode( errorCode ) ); return( null ); }