By default, the DataBlade
API stops
the current statement when the statement generates a database runtime
error and continues execution when the statement generates a database
warning.
To override the default exception handling, you must take
the following actions:
- Write a callback function that handles the MI_Exception
event.
To handle an MI_Exception event, you can write
either of the following types of callback functions:
- Exception callback, which executes only when the MI_Exception
event occurs
- All-events callback, which executes when many events occur and
can include handling for the MI_Exception event
Within a callback, the DataBlade
API function mi_error_level() returns
the exception level for the database server exception. You can also
use mi_error_sql_state(), mi_error_sqlcode(),
and mi_errmsg() to get more details about the database
server exception from its error descriptor.
- Register the callback that handles the MI_Exception event
in the DataBlade
API module
that needs the exception handling.
Use the mi_register_callback() function
to register callback functions. After you register a callback that
handles the MI_Exception event, the DataBlade
API invokes
this callback instead of performing its default exception handling
for the event.
Important: Exception callbacks
are subject to some restrictions on what tasks they can perform.
A
database server exception triggers an exception callback only if the DataBlade
API module
has registered (and enabled) a callback that handles the MI_Exception
event. The way that your DataBlade
API module
handles a database server exception depends on whether the DataBlade
API module
is a UDR or a client LIBMI application.