Displaying Error Messages

From InterBase

Go Up to Additional InterBase Error Handling


If SQLCODE is less than –1, additional InterBase error information can be displayed using the InterBase isc_print_sqlerror() function inside an error-handling routine. During preprocessing with gpre, this function is automatically declared for InterBase applications.

isc_print_sqlerror() displays the SQLCODE value, a related SQL error message, and any InterBase error messages in the status array. It requires two parameters: SQLCODE, and a pointer to the error status array, isc_status.

For example, when an error occurs, the following code displays the value of SQLCODE, displays a corresponding SQL error message, then displays additional InterBase error message information if possible:

. . .
EXEC SQL
SELECT CITY INTO :city FROM STATES
WHERE STATE = :stat:statind;
if(SQLCODE)
{
isc_print_sqlerror(SQLCODE, isc_status);
EXEC SQL
ROLLBACK;
EXEC SQL
DISCONNECT ALL;
exit(1);
}
. . .
Important: Some windowing systems do not encourage or permit direct screen writes. Do not use isc_print_sqlerror() when developing applications for these environments. Instead, use isc_sql_interprete() and isc_interprete() to capture messages to a buffer for display.

Advance To: