Displaying SQL Error Messages
From InterBase
Go Up to Setting a SQLCODE Value on Error
API applications that provide a DSQL interface to end users should use isc_print_sqlerror()
to display SQL error codes and corresponding error messages on the screen. When passed a variable, conventionally named SQLCODE
, containing a SQL error code, and a pointer to the status vector, isc_print_sqlerror()
parses the status vector to build a SQL error message, then uses the C printf()
function to write the SQLCODE
value and message to the display. For example, the following code fragment calls isc_print_sqlerror()
and rolls back a transaction on error:
#include <ibase.h>
. . .
ISC_STATUS status_vector[20];
isc_tr_handle trans;
long SQLCODE;
. . .
trans = 0L;
. . .
/* Assume a transaction, trans, is started here. */
/* Assume an API call returning status information is called here. */
if (status_vector[0] == 1 && status_vector[1] > 0) {
SQLCODE = isc_sqlcode(status_vector);
isc_print_sqlerror(SQLCODE, status_vector);
isc_rollback_transaction(status_vector, &trans);
}
Important:
On windowing systems that do not permit direct screen writes with
On windowing systems that do not permit direct screen writes with
printf()
, use isc_sql_interprete()
to capture error messages to a buffer.