Contents Index handle_error connection event modify_last_download_timestamp connection event

MobiLink Synchronization Reference
  Synchronization Events

handle_odbc_error connection event


Function 

Executed whenever the MobiLink synchronization server encounters an error triggered by the ODBC Driver Manager.

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 is an INOUT parameter.
2 ODBC_state VARCHAR(5)
3 error_message TEXT
4 ml_username VARCHAR(128)
5 table VARCHAR(128)
Default action 

The MobiLink synchronization server selects a default action code. You can modify the action code in the script, and return a value instructing MobiLink how to proceed. The action code parameter takes one of the following values:

Description 

The MobiLink synchronization server executes this script whenever it encounters an error flagged by the ODBC Driver Manager during the synchronization process. The error codes allow you to identify the nature of the error.

The action code tells the MobiLink synchronization server what to do next. Before it calls this script, the MobiLink synchronization server sets the action code to a default value, which depends upon the severity of the error. Your script may modify this value. Your script must return or set an action code.

The handle_odbc_error script is called after the handle_error and report_error scripts, and before the report_odbc_error script.

When only one, but not both, error-handling script is defined, the return value from that script decides error behavior. When both error-handling scripts are defined, the MobiLink synchronization server uses the numerically highest action code. If both handle_error and handle_ODBC_error are defined, MobiLink uses the numerically highest action code returned from all calls.

See also 

handle_error connection event

report_error connection event

report_odbc_error connection event

SQL example 

The following example works with an Adaptive Server Anywhere consolidated database. It allows your application to ignore ODBC integrity constraint violations.

call ml_add_connection_script(
 'ver1',
 'handle_odbc_error',
 'call HandleODBCError( ?, ?, ?, ?, ? )'  )
CREATE PROCEDURE HandleODBCError( INOUT action integer,
IN odbc_state varchar(5), IN error_message varchar(1000),
IN user_name varchar(128), IN table_name varchar(128) )
BEGIN
  if odbc_state = '23000' then
      -- ignore the error and keep going
      SET action = 1000;
  else
      -- abort the synchronization
      SET action = 3000;
  end if;
END
Java example 

The following stored procedure call registers a Java method called handleODBCError as the script for the handle_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', 'handle_odbc_error', 'ExamplePackage.ExampleClass.handleODBCError' )

Following is the sample Java method handleODBCError. It processes an error based on the data that is passed in. It also determines the resulting error code.

public String handleODBCError(
  ianywhere.ml.script.InOutInteger actionCode,
  String ODBCState,
  String errorMessage,
  String user,
  String table )
{  int new_ac;
   if( user == null )
   {  new_ac = handleNonSyncError( ODBCState,
      errorMessage ); }
   else if( table == null )
   {  new_ac = handleConnectionError( ODBCState,
      errorMessage, user ); }
   else {  new_ac = handleTableError( ODBCState,
           errorMessage, user, table ); }
   // keep the most serious action code
   if( actionCode.getValue() < new_ac )
   {  actionCode.setValue( new_ac ); }
   return( null ); }

Contents Index handle_error connection event modify_last_download_timestamp connection event