Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
An error in a synchronization script occurs when an operation in the script fails while the MobiLink server is executing it.
For SQL scripts, the DBMS returns a SQLCODE and error message to the MobiLink server indicating the nature of the error. Each consolidated database DBMS has its own set of SQLCODEs and messages. By default, the MobiLink server rolls back the transaction in the consolidated database, logs the error, and aborts the synchronization.
When an error occurs during the invocation of a SQL data script, the MobiLink server invokes the handle_error or handle_odbc_error events. When these error-handling scripts are defined, the MobiLink server invokes them and passes several parameters providing information about the nature and context of the error. One parameter is an output value, called the action_code, to tell MobiLink server how to respond to the error. The action_code tells the MobiLink server to either ignore the error or abort the synchronization.
The error-handling scripts do not get invoked for all SQL errors. Only data scripts cause the error-handling scripts to be invoked. When errors occur in non-data scripts, the MobiLink server rolls back the transaction in the consolidated database, logs the error, and aborts the synchronization.
If your consolidated DBMS supports exception handling, consider using it instead of the error-handling scripts, particularly if you need to ignore certain errors in data scripts. Using exception handling will almost always perform better than the error-handling scripts.
If the handle_error or handle_odbc_error script itself causes an error, the MobiLink server rolls back the transaction in the consolidated database, logs the error, and aborts the synchronization.
Some actions you may want to take in an error-handling script are:
Ignore the error, but log it in an audit table.
Instruct the MobiLink server to rollback the synchronization.
Send an email alert message.
ODBC allows multiple errors per SQL statement, and some RDBMSs make use of this feature. Microsoft SQL Server, for example, can have two errors for a single statement. The first is the actual error, and the second is usually an informational message telling you why the current statement has been terminated.
When a single SQL statement causes multiple errors, the handle_error script is invoked once per error. The MobiLink server uses the most severe action code (that is, the numerically greatest) to determine the action to take. The same applies to the handle_error script.
If the handle_error script itself causes a SQL error, then the default action code (3000) is assumed.