MOVE ZEROES TO WS-LASTNAME-IND
INTO :WS-LAST :WS-LASTNAME-IND
WHERE EMPNO = :WS-EMPNO
IF WS-LASTNAME-IND < ZEROES
WS-LASTNAME-IND --- Need to define the null indicator variable with s9(04) comp in Working storage
We can test the indicator variable WS-LASTNAME-IND for a negative value. If it is negative, the corresponding value in the host variable WS-LAST is NULL, and therefore, the contents of WS-LAST can be disregarded.
It is not necessary to initialize the WS-LASTNAME-IND before the SQL statement. DB2 will place a negative value or zero based on the contents of the column (NULL or NOT). But it is good programming practice to initialize all host variables and indicator variables.
If the indicator variable is not specified and a NULL value is returned, DB2 will flag an error condition and the value in the WS-LAST column is undefined and unpredictable.