Allows you to log errors and to record the actions selected by the handle_odbc_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.
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.action_code |
INTEGER. This is an INOUT parameter. This parameter is mandatory. |
1 |
s.ODBC_state |
VARCHAR(5). |
2 |
s.error_message |
TEXT. |
3 |
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. |
4 |
s.table |
VARCHAR(128). |
5 |
None.
This script allows you to log errors and to record the actions selected by the handle_odbc_error script. This script is executed after the handle_odbc_error event, whether a handle_odbc_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.
The following example works with a SQL Anywhere consolidated database. It inserts a row into a table used to record synchronization errors.
CALL ml_add_connection_script( 'ver1', 'report_odbc_error', 'INSERT INTO sync_error( action_code, odbc_state, error_message, user_name, table_name ) VALUES( {ml s.action_code}, {ml s.ODBC_state}, {ml s.error_message}, {ml s.username}, {ml s.table} )' ) |
The following call to a MobiLink system procedure registers a Java method called reportODBCError as the script for the report_odbc_error event when synchronizing the script version ver1.
CALL ml_add_java_connection_script( 'ver1', 'report_odbc_error', 'ExamplePackage.ExampleClass.reportODBCError' ) |
The following is the sample Java method reportODBCError. It logs the error to a table using the JDBC connection provided by MobiLink. It also sets the action code.
public String reportODBCError( ianywhere.ml.script.InOutInteger actionCode, String ODBCState, String errorMessage, String user, String table ) throws java.sql.SQLException { JDBCLogError( _syncConn, ODBCState, errorMessage, user, table ); actionCode.setValue( getActionCode( ODBCState ) ); return ( null ); } |
The following call to a MobiLink system procedure registers a .NET method called ReportODBCError as the script for the report_odbc_error event when synchronizing the script version ver1.
CALL ml_add_dnet_connection_script( 'ver1', 'report_odbc_error', 'TestScripts.Test.ReportODBCError' ) |
The following is the sample .NET method ReportODBCError. It logs the error to a table using a .NET method.
public string ReportODBCError ( ref int actionCode, string ODBCState, string errorMessage, string user, string table ) { LogError(_syncConn, ODBCState, errorMessage, user, table); return ( null ); } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |