SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-47
WHENEVER
Updating a Column With a Null Value
This example updates a column by setting the column to a null value using an indicator
variable. This example uses the TACL DEFINE name =EMPLOYEE for the
EMPLOYEE table.
! Variable declarations:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INVOKE =employee AS emp^tbl;
STRUCT .emp(emp^tbl);
INT ind^1;
EXEC SQL END DECLARE SECTION;
...
! Executable statements:
ind^1 := -1;
EXEC SQL
UPDATE =employee
SET salary =:emp.salary INDICATOR :ind^1
WHERE jobcode = :hostvar^jobcode;
This example uses the NULL keyword instead of an indicator variable:
EXEC SQL
UPDATE =employee SET salary = NULL
WHERE jobcode = :hostvar^jobcode;
WHENEVER
The WHENEVER directive specifies an action that a program takes depending on the
outcome of subsequent statements DML, DCL, and DDL SQL statements. For a
description of the WHENEVER directive, see Section 6, Error and Status Processing.