NOT FOUND Keywords

If you use the NOT FOUND keywords, exception handling for SELECT and FETCH statements (including implicit SELECT and FETCH statements in FOREACH and UNLOAD statements) is treated differently from other SQL statements. The NOT FOUND keyword checks for the following cases:
  • The End of Data condition: a FETCH statement that attempts to get a row beyond the first or last row in the active set
  • The Not Found condition: a SELECT statement that returns no rows

In each case, the sqlcode variable is set to 100, and the SQLSTATE variable has a class code of 02. For the name of the sqlcode variable in each Informix® product, see the table in SQLERROR Keyword.

The following statement calls the no_rows( ) function each time the NOT FOUND condition exists:
WHENEVER NOT FOUND CALL no_rows

If you do not use any WHENEVER NOT FOUND statements in a program, the default action for WHENEVER NOT FOUND is CONTINUE.