The mi_error_sql_state() function
The mi_error_sql_state() function retrieves the value of the SQLSTATE status variable from an error descriptor.
Syntax
mi_integer mi_error_sql_state(err_desc, sqlstate_buf, buflen)
MI_ERROR_DESC *err_desc;
char *sqlstate_buf;
mi_integer buflen;
- err_desc
- A pointer to the error descriptor that describes the SQL error or warning.
- sqlstate_buf
- A pointer to a buffer to contain the SQLSTATE value from the err_desc error descriptor.
- buflen
- The allocated size of the sqlstate_buf buffer. It must be at least six bytes long; otherwise, mi_error_sql_state() raises an exception.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Yes | Yes |
Usage
The mi_error_sql_state() function
copies the value of the SQLSTATE status variable from the error
descriptor that err_desc references into the user-allocated
buffer that sqlstate_buf references. The SQLSTATE status
value is a sequence of five ASCII characters with a null byte at the
end. To indicate success, SQLSTATE contains a value of "00000
".
Other values indicate types of warnings and runtime errors. In particular,
an SQLSTATE value of "IX000"
indicates a database
server-specific error, which the value of SQLCODE identifies.
You can use the mi_error_sqlcode() function to
obtain the SQLCODE value from an error descriptor.
This function is intended for use with the MI_ERROR_DESC structure passed to a callback routine when the callback exception is of event type MI_Exception.
For general information about how to obtain information from an error descriptor, see the Informix® DataBlade® API Programmer's Guide.
Return values
- MI_OK
- The function was successful.
- MI_ERROR
- The function was not successful.