SQLERROR Keyword

If you use the SQLERROR keyword, any SQL statement that encounters an error is handled as the WHENEVER SQLERROR statement directs. If an error occurs, the sqlcode variable (sqlca.sqlcode, SQLCODE) is set to a value less than zero (0) and the SQLSTATE variable is set to a class code with a value greater than 02.

The next example terminates program execution if an SQL error is detected:
WHENEVER SQLERROR STOP

If you do not include any WHENEVER SQLERROR statements in a program, the default action for WHENEVER SQLERROR is CONTINUE.