Informix® GLS exceptions
Many of the functions return a unique value if they encounter an error. To further identify the cause of the error, you can use the ifx_gl_lc_errno() function to obtain the value of the error number.
The ifx_gl_lc_errno() function returns the error number as an int value. library functions can use ifx_gl_lc_errno() to obtain more information about an error that has occurred. The functions set the error number only if an error occurs unless a particular function is documented otherwise.
Because any library function can set the error number, you must call ifx_gl_lc_errno() immediately after the function in which the error occurred to inspect the relevant value of the error number.
if ( ifx_gl_mbslen(mbs, n) == -1 )
switch ( ifx_gl_lc_errno() )
...
ifx_gl_lc_errno() = 0;
(void) ifx_gl_mbslen(mbs, n);
if ( ifx_gl_lc_errno() != 0 )
switch ( ifx_gl_lc_errno() )
...
ifx_gl_lc_errno() = 0;
value = ifx_gl_ismupper(mb, IFX_GL_NO_LIMIT);
if ( ifx_gl_lc_errno() != 0 )
switch ( ifx_gl_lc_errno() )
...
int wrong_func()
{
ifx_gl_lc_errno() = 0; /* A memory fault will occur here. */
(void) ifx_gl_init();
if ( ifx_gl_lc_errno() != 0 )
switch ( ifx_gl_lc_errno() )
...
In the preceding code fragment, the ifx_gl_lc_errno() function can write or read the error number only after a call to the ifx_gl_init() function has correctly initialized the current processing locale.
int right_func()
{
(void) ifx_gl_init();
ifx_gl_lc_errno() = 0;
if ( ifx_gl_lc_errno() != 0 )
switch ( ifx_gl_lc_errno() )
...
For multithreaded ESQL/C applications, the error-number value is stored as a field in the thread control block. Therefore, multithreaded ESQL/C applications can use the error number.