Identify runtime errors with SQLSTATE
When an SQL statement results in a runtime error, the database
server takes the following actions:
- Sets the class code of SQLSTATE to a value greater than
"02"
(see Status conditions in SQLSTATE). - Sets the subclass code of SQLSTATE to a unique value that indicates the cause of the error.
- Raises an MI_Exception event with an MI_EXCEPTION exception level.
The class and subclass codes of SQLSTATE identify the particular
error. For errors that are specific to HCL Informix® (SQLSTATE is
"
IX000
"), you can also check the value of the SQLCODE variable
to identify the error.Tip: The database server sets SQLSTATE to
"02000"
(class
= "02"
) when a SELECT or FETCH statement encounters
NOT FOUND (or END OF DATA). However, the NOT FOUND condition does
not cause a database server exception. Therefore, you do not use SQLSTATE to
detect this condition from within a callback of a DataBlade®
API module.
Instead, your DataBlade®
API module
can check for the MI_NO_MORE_RESULTS return code from the mi_get_result() function.