Error messages

The database server cannot validate specifications for features that the access method adds. If the access method includes a feature that the database server cannot detect, the access method must explicitly handle syntax errors in requests for that feature. To handle errors that the database server cannot detect, call the DataBlade® API mi_db_error_raise() function.

The following example shows you how an access method might avoid an unexpected exit due to a user error that the database server cannot detect. The CREATE TABLE statement in this example specifies configuration parameters.
CREATE TABLE legacy
...
USING text_file_access(delimiter = '!')
The access method notifies a user if a statement specifies an invalid parameter. To determine the parameters that a CREATE TABLE statement specifies, the access method calls the accessor function mi_tab_amparam(). To notify a user of an invalid parameter, the access method raises an exception, as the following example shows:
if (mi_tab_amparam(tableDesc) != 'delimiter')
   mi_db_error_raise( connection, MI_EXCEPTION, 
      "Invalid configuration keywordin the USING clause.");

The MI_EXCEPTION alerts the database server that an exception has occurred. If the function that called mi_db_error_raise() has registered a callback for MI_Exception (upper and lowercase), that callback is executed to handle the error.

For more information about callbacks, see the Informix® DataBlade API Programmer's Guide.
Important: The connection handle argument to mi_db_error_raise() must be valid, not NULL, and it must have the same value as the one used in mi_register_callback().

The database server cannot always determine that the access method does not support a feature that a user specifies. The access method can test for the presence of specifications and either provide the feature or raise an exception for those features that it cannot provide.

For example, the database server does not know if the access method can handle lock types, isolation levels, referential constraints, or fragmentation that an SQL statement specifies. To retrieve the settings for mode, isolation level, and lock, the access method calls the following accessor functions:
mi_tab_mode()
The input and output mode (read-only, read and write, write only, and log transactions)
mi_tab_isolevel()
The isolation level
mi_scan_locktype()
The lock type for the scan
mi_scan_isolevel()
The isolation level in force