INFORMIX
DataBlade API Programmer's Manual
Chapter 9: Event and Exception Handling
Home Contents Index Master Index New Book

Exception Handling

When an exception is raised in the database server or in a user-defined routine, any callbacks registered for the exception are invoked. In addition, in the server DataBlade API, a callback can declare that it has handled the exception and that the exception is not to be propagated.

A user callback routine halts propagation of an exception with MI_CB_EXC_HANDLED. The callback can substitute its own actions for any actions that would have been taken had the exception been propagated, or it can do nothing at all.

The following example illustrates exception handling. The user function, myfunc(), is a server function that registers a callback named myhandler and uses mi_exec() to send a statement string that causes a syntax error in the database server.

The user callback myhandler() catches and claims to handle the exception.

This callback suppresses any actions that the database server might take, such as aborting the statement. If no user callback existed for this exception, or if the callback did not handle the exception, the database server would handle the exception, and the callback function would return a message. However, myhandler() prevents the database server from handling the exception, and the caller myfunc() simply returns.




DataBlade API Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.