skip to main content

Embedded SQL Statements : WHENEVER

WHENEVER
The WHENEVER statement allows the handling of error and exception conditions.
General format
EXEC SQL
  WHENEVER { SQLERROR   } [ DO ] { GO TO Host-Label  }
           { SQLWARNING }        { CALL Host-Label   }
           { NOT FOUND  }        { PERFORM Host-Label}
Syntax rules
1.
Host-Label is a User-defined word, as defined in the Definitions section of the Preface of this document.
General rules
1.
When SQLERROR is specified, the specified action is performed when the SQL statement generates an error.
2.
When SQLWARNING is specified, the specified action is performed when the SQL statement generates a warning.
3.
When NOT FOUND is specified, the specified action is performed when the SQL statement affects no rows.
4.
When GO TO is specified, the control is transferred to the COBOL paragraph or section identified by Host-Label.
5.
When CONTINUE is specified, the program continues to the next statement. If a fatal error occurs, an error condition is generated and the program aborts.
Examples
Set the general SQL error procedure
   exec sql
   end-exec
   if sqlcode not = 0
      display message sqlcode   x"0d0a"
      exec sql disconnect all end-exec
   end-if

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left