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 FORM
instruction, 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
INSERT
statement violates aUNIQUE
table constraint, or when doing aFETCH
on an unopened cursor. -
SQL not found : When an SQL statement returns no data row(s). For example, when a
FETCH
statement 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
VARCHAR
variable is not long enough.
The default action can be changed by specifying the exception class in the
WHENEVER
instruction.
ERROR
orSQLERROR
- Triggered by a Language error or SQL error. Default exception action
is
STOP
. TheWHENEVER [SQL]ERROR
andWHENEVER ANY [SQL]ERROR
directives are mutually exclusive.
ANY ERROR
orANY SQLERROR
- Triggered by a Language error, SQL error or Expression
error. The
WHENEVER ANY [SQL]ERROR
andWHENEVER [SQL]ERROR
directives are mutually exclusive.WHENEVER ANY ERROR
has 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 FOUND
directive can be specified independently from other exception classes.
WARNING
- SQL statements setting
sqlca.sqlawarn
flags. Default exception action isCONTINUE
. The action forWHENEVER WARNING
directive can be specified independently from other exception classes.
WHENEVER
instruction defines the behavior for
the ANY ERROR
exception
class:WHENEVER ANY ERROR CONTINUE