Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Error handling

There are two ways of taking appropriate action if an SQL statement was unsuccessful:

  • Query SQLSTATE and branch according to the status code

  • Use the WHENEVER statement

    You can use WHENEVER to specify that, after execution of an SQL statement with an SQLSTATE ≠ '00xxx' and ≠ '01xxx', the program is to continue executing or is to branch to a certain part of the program where error handling is performed. You can specify branching within the program for two error classes:

    • NOT FOUND: no data available, e.g. when the end of a table is reached

    • SQLERROR: other errors that result in abortion of SQL statements

    You can specify the WHENEVER statement more than once in a program. The specifications made in a WHENEVER statement are valid for all subsequent SQL statements in the program text up to the next WHENEVER statement for the same error class.