Error Handling (Language Reference Guide)

From InterBase
Jump to: navigation, search

Go Up to SQL Statement and Function Reference


Every time an executable SQL statement is executed, the SQLCODE variable is set to indicate its success or failure. No SQLCODE is generated for declarative statements that are not executed, such as DECLARE CURSOR, DECLARE TABLE, and DECLARE STATEMENT.

The following table lists values that are returned to SQLCODE:

SQLCODE and message summary
SQLCODE Message Meaning

< 0

SQLERROR

Error occurred; statement did not execute

0

SUCCESS

Successful execution

+1–99

SQLWARNING

System warning or informational message

+100

NOT FOUND

No qualifying rows found, or end of current active set of rows reached

When an error occurs in isql, InterBase displays an error message.

In embedded applications, the programmer must provide error handling by checking the value of SQLCODE.

To check SQLCODE, use one or a combination of the following approaches:

  • Test for SQLCODE values with the WHENEVER statement.
  • Check SQLCODE directly.
  • Use the isc_print_sqlerror( ) routine to display specific error messages.

For more information about error handling, see the Embedded SQL Guide.