Error handling and exception support

<< isql prompts | Firebird Interactive SQL Utility | Transaction handling >>

Error handling and exception support

Exception handling is a programming construct designed to handle an occurrence that disrupts the normal execution of a program. These are called errors. Exceptions are user-defined named error messages, written specifically for a database and stored in that database for use in stored procedures and triggers.

For example, if it is ascertained in a trigger that the value in a table is incorrect, the exception is fired. This leads to a rollback of the total transaction that the client application is attempting to commit. Exceptions can be interleaved, and shared among the different modules of an application, and even among different applications sharing a database. They provide a simple way to standardize the handling of preprogrammed input errors.

Exceptions are database objects, like tables, views and domains, and are part of the database's metadata. They can be created, modified and dropped like all other Firebird objects using isql.

In isql, error messages comprise the SQLCODE variable and the Firebird status array. The following table provides some examples:

Table 2. isql error codes and messages

SQLCODEMessageMeaning
<0SQLERRORError occurred: statement did not execute
0SUCCESSSuccessful execution
+1 to +99SQLWARNINGSystem warning or information message
+100NOT FOUNDNo qualifying rows found, or end of current active set of rows reached

back to top of page
<< isql prompts | Firebird Interactive SQL Utility | Transaction handling >>