Exception classes
Exception classes define the kind of issues that can occur at runtime.
-
Language errors : In case of invalid use of language instructions or API. For example, when specifying an unexisting form with the
OPEN FORMinstruction, or when opening an unexisting file withbase.Channel.openFile(). -
Expression errors : When an expression evaluation produces an error. For example, when a character string cannot be converted to a number type.
-
SQL errors : If an SQL statement execution or SQL instruction returns an error. For example, when an
INSERTstatement violates aUNIQUEtable constraint, or when doing aFETCHon an unopened cursor. -
SQL not found : When an SQL statement returns no data row(s). For example, when a
FETCHstatement reaches the end of the SQL cursor result set. -
SQL Warnings : If an SQL statement produces warning(s). For example, when fetching a character string value that gets truncated because the target
VARCHARvariable is not long enough.
The default action can be changed by specifying the exception class in the
WHENEVER instruction.
ERRORorSQLERROR- Triggered by a Language error or SQL error. Default exception action
is
STOP. TheWHENEVER [SQL]ERRORandWHENEVER ANY [SQL]ERRORdirectives are mutually exclusive.
ANY ERRORorANY SQLERROR- Triggered by a Language error, SQL error or Expression
error. The
WHENEVER ANY [SQL]ERRORandWHENEVER [SQL]ERRORdirectives are mutually exclusive.WHENEVER ANY ERRORhas no default action, because the default isWHENEVER ERROR STOP, where Expression errors do not stop the program execution.
NOT FOUND- Triggered by SQL statements returning status
NOTFOUND. Default exception action isCONTINUE. The action forWHENEVER NOT FOUNDdirective can be specified independently from other exception classes.
WARNING- SQL statements setting
sqlca.sqlawarnflags. Default exception action isCONTINUE. The action forWHENEVER WARNINGdirective can be specified independently from other exception classes.
WHENEVER instruction defines the behavior for
the ANY ERROR exception
class:WHENEVER ANY ERROR CONTINUE