The mi_unregister_callback() function

The mi_unregister_callback() function unregisters a callback for an event type or for all event types.

Syntax

mi_integer mi_unregister_callback(conn, event_type, cback_handle)
   MI_CONNECTION *conn;
   MI_EVENT_TYPE event_type;
   MI_CALLBACK_HANDLE *cback_handle;
conn
This value is either NULL or a pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
event_type
The event type for the callback. For a list of valid event types, see the HCL OneDB™ DataBlade® API Programmer's Guide.
cback_handle
The callback handle that a previous call to mi_register_callback() returned.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_unregister_callback() function unregisters the callback that cback_handle identifies for the event that event_type specifies.

Server only: For a C UDR, conn must be NULL for the following event types:
  • MI_EVENT_SAVEPOINT
  • MI_EVENT_COMMIT_ABORT
  • MI_EVENT_POST_XACT
  • MI_EVENT_END_STMT
  • MI_EVENT_END_XACT
  • MI_EVENT_END_SESSION
Client only: For a client LIBMI application, you must provide a valid connection descriptor to the mi_retrieve_callback() function for callbacks that handle the following event types:
  • MI_Exception
  • MI_Xact_State_Change
  • MI_Client_Library_Error
The mi_register_callback() function registers a callback. The database server automatically unregisters a callback when either of the following occurs:
  • For a state-transition callback, an end-of-statement (MI_EVENT_END_STMT), end-of-transaction (MI_EVENT_END_XACT), or end-of-session (MI_EVENT_END_SESSION) event occurs and the associated callback completes.
  • The associated connection is closed (either the UDR exits or the mi_close() function executes).
Use the mi_unregister_callback() function to explicitly unregister a callback so that the database server does not invoke it when the event_type event occurs.
Important: It is recommended that you explicitly unregister a callback function with mi_unregister_callback() once you no longer need it. Otherwise, the registration remains in effect until the associated session closes.

For a description of how to register and unregister a callback, see the HCL OneDB DataBlade API Programmer's Guide.

Return values

MI_OK
The function was successful; the callback was unregistered.
MI_ERROR
The function was not successful.