Standard Error Handling

From InterBase

Go Up to Error Handling and Recovery

Every time a SQL statement is executed, it returns a status indicator in the ­SQLCODE variable, which is declared automatically for SQL programs during preprocessing with gpre. The following table summarizes possible SQLCODE values and their meanings:

Possible SQLCODE values
Value Meaning




Warning or informational message


End of file (no more data)

< 0

Error. Statement failed to complete

To trap and respond to run-time errors, SQLCODE should be checked after each SQL operation. There are three ways to examine SQLCODE and respond to errors:

  • Use WHENEVER statements to automate checking SQLCODE and handle errors when they occur.
  • Test SQLCODE directly after individual SQL statements.
  • Use a judicious combination of WHENEVER statements and direct ­testing.

Each method has advantages and disadvantages, described fully in the remainder of this chapter.


Advance To: