Contents Index report_error connection event resolve_conflict table event

MobiLink Synchronization Reference
  Synchronization Events

report_odbc_error connection event


Function 

Allows you to log errors and to record the actions selected by the handle_odbc_error script.

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.

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 ODBC_state VARCHAR(5). 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.
Default action 

None.

Description 

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 or not 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.

See also 

handle_error connection event

handle_odbc_error connection event

report_error connection event

SQL example 

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_odbc_error',
 'insert into sync_error(
    action_code,
    odbc_state,
    error_message,
    user_name,
    table_name )
  values( ?, ?, ?, ?, ? )'  )
Java example 

The following stored procedure call registers a Java method called reportODBCError as the script for the report_odbc_error event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_java_connection_script(
   'ver1',
   'report_odbc_error',
   'ExamplePackage.ExampleClass.reportODBCError' )

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 ); }

Contents Index report_error connection event resolve_conflict table event