|
The mi_db_error_raise() function raises an error or warning and sends the message to the calling program.
The mi_db_error_raise() raises an MI_Exception event to the database server. If the DataBlade API program registers a callback function to handle MI_Exception events, the database server invokes this callback. By default, the client application receives any messages that mi_db_error_raise() raises, regardless of how the exception is raised on the database server.
In a client LIBMI application, the conn parameter of mi_db_error_raise() must be a valid connection descriptor. When a client LIBMI application invokes the mi_db_error_raise() function, the exception is passed to the database server for processing. If the client LIBMI application has not registered a callback for MI_Exception, the database server executes the system-default callback (which the mi_default_callback() function implements).
The conn parameter can be either of the following values:

For more information, see Specifying the Connection.
You can use the mi_db_error_raise() function either to pass a literal message or to raise an SQL error or warning stored in the syserrors system catalog table. The msg_type parameter can contain one of the following values.
For example, the following call to mi_db_error_raise() raises an MI_Exception event with an exception level of MI_MESSAGE, an SQLSTATE value of "01U01", and the "Operation Successful " warning message:
For the following line, mi_db_error_raise() raises an MI_Exception event with an exception level of MI_EXCEPTION, an SQLSTATE value of "U0001", and the "Out of Memory!!! " error message:
The syserrors system catalog table stores the text of custom error and warning messages along with their five-character SQLSTATE value. A DataBlade module can store module-specific error and warning messages in syserrors.
The locale column of the syserrors system catalog table is used for the internationalization of error and warning messages. Using the syserrors catalog table is recommended to maintain language independence of messages. For more information on internationalized exception messages, see the Informix Guide to GLS Functionality.
The following call to mi_db_error_raise() returns the predefined SQL message that is associated with an SQLSTATE value of "03I01" and has no markers:
Custom messages can contain parameter markers, whose values the optional_parameters parameter specifies. The optional_parameters parameter list specifies a pair of values for each parameter marker in the message and is terminated with a NULL-valued pointer.
See the descriptions of the following functions: mi_default_callback(), mi_errmsg(), mi_error_desc_copy(), mi_error_desc_destroy(), mi_error_desc_is_copy(), mi_error_level(), mi_error_sql_state(), and mi_register_callback().
For more information on how to raise exceptions, see Raising an Exception.