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

0

Success

1–99

Warning or informational message

100

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.

Topics

Advance To: