Exceptions in a C UDR (Server)

If a C UDR has not registered an exception callback on the current connection, the DataBlade® API takes a default action based on the exception level of the MI_Exception event.

For the following example, the return statement never executes when a runtime error occurs in the SQL statement that mi_exec() executes.
mi_integer
no_exception_handling(flag)
   mi_integer flag;
{
   MI_CONNECTION *conn;

   conn = mi_open(NULL, NULL, NULL);
   mi_exec(conn, "bad SQL statement", MI_QUERY_NORMAL);

/* Not reached; this function aborts on an exception. */
...
   return 1;
}

When an exception with an MI_EXCEPTION exception level occurs, the DataBlade® API ends the mi_exec() call and the no_exception_handling() routine. The database server returns control to the calling module.

To provide event handling for database server exceptions within a UDR, perform the following tasks:
  • Determine if a callback can handle the runtime error.
  • In the UDR, register a callback that handles the MI_Exception event.
  • In the callback function, return a value that determines how to continue the exception handling once the callback completes.