The mi_error_sqlcode() function

The mi_error_sqlcode() function retrieves the value of the HCL OneDB™ SQLCODE status variable from an error descriptor.

Syntax

mi_integer mi_error_sqlcode(err_desc, sqlcode_ptr)
   MI_ERROR_DESC *err_desc;
   mi_integer *sqlcode_ptr;
err_desc
A pointer to the error descriptor that describes the SQL error or warning.
sqlcode_ptr
A pointer to the SQLCODE value that mi_error_sqlcode() is to obtain from the err_desc error descriptor.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_error_sqlcode() function copies the value of the HCL OneDB SQLCODE status variable from the error descriptor that err_desc references into the user-allocated variable that sqlcode_ptr references. The SQLCODE variable contains an integer value that is 0 to indicate success and negative to indicate an error.

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. You can use the mi_error_sqlcode() function to retrieve an SQLCODE value to provide more information about cases in which SQLSTATE indicates an error specific to HCL OneDB ("IX000" value).

A separate, additional callback follows the callback for the SQLCODE value when an exception has an access-method error code (HCL OneDB RSAM status). This error code and message text are available through the mi_errmsg() and mi_error_sqlcode() functions.

If no SQLCODE value is defined, as for mi_db_error_raise() exceptions, mi_error_sqlcode() sets sqlcode_ptr to 0.
Tip: The SQLSTATE variable is an ANSI-complaint way to indicate errors. The SQLCODE variable is specific to HCL OneDB. If your application is to be ANSI compliant, use SQLSTATE rather than SQLCODE.

For general information about how to obtain information from an error descriptor, see the HCL OneDB DataBlade® API Programmer's Guide.

Return values

MI_OK
The function was successful.
MI_ERROR
The function was not successful.