SQL Programming Manual for Pascal

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal528614-001
3-42
Updating Columns With Null Values
Updating Columns With Null Values
The following 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 EMPTBL_TYPE ;
VAR EMPTBL : EMPTBL_TYPE;
IND_1 : INT16;
EXEC SQL END DECLARE SECTION ;
...
{ Procedure Code: }
IND_1 := -1;
EXEC SQL
UPDATE =EMPLOYEE
SET SALARY =:EMPTBL.SALARY INDICATOR :IND_1
WHERE EMPTBL.JOBCODE = 1007;
The following example uses the NULL keyword instead of an indicator variable:
EXEC SQL
UPDATE =EMPLOYEE SET SALARY = NULL
WHERE JOBCODE = 1007;
WHENEVER
The WHENEVER directive specifies an action that a program takes depending on the
outcome of subsequent DML, DCL, and DDL SQL statements. For a description of the
WHENEVER directive, see Section 6, Error and Status Processing.