The whenever statement specifies one of the following five actions:
Action |
Description |
---|---|
continue |
Causes no special action when a SQL statement returns the specified condition. Normal processing continues. |
goto |
Causes a branch to an error-handling procedure within your application program. You can enter goto as either “goto” or “go to”, followed by a valid paragraph name. The precompiler does not detect an error if the paragraph name is not defined in the program, but the COBOL compiler does. |
call |
Calls another COBOL program and, optionally, passes variables. |
perform |
Names at least one paragraph to execute when a SQL statement results in the specified condition. You can use the COBOL perform statement formats 1, 2, 3, and 4 in the perform clause. If you use a paragraph name, the paragraph must be in the section where the whenever condition applies. |
stop |
Terminates the program when a SQL statement triggers the specified condition. |
. . .
exec SQL whenever sqlerror perform ERR-PARA
thru ERR-PARA-END
end-exec
. . .
exec SQL select au_lname from authors
into :AU-LNAME
where au_id = :AU-ID
end-exec
. . .
exec SQL update authors set au_lname = :AU-LNAME
where au_id = :AU-ID
end-exec
. . .