SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
4-20
Testing for Null or a Truncated Value
 MOVE -1 TO RETIRE-IND.
 EXEC SQL
 INSERT INTO persnl.retirees
 VALUES (:NEW-EMPNUM,:RETIRE-DATE INDICATOR :RETIRE-IND)
 END-EXEC. 
 ...
This example uses the NULL keyword instead of an indicator variable to insert the null 
value:
 ...
 EXEC SQL
 INSERT INTO persnl.retirees VALUES (:NEW-EMPNUM, NULL)
 END-EXEC.
Testing for Null or a Truncated Value
To test for null or a truncated character value, check the indicator variable associated 
with a host variable. If the value of the indicator variable is less than zero, the 
associated column contains null. If the value of the indicator variable is greater than 
zero, character data in the column was truncated when it was assigned to the host 
variable. 
Example
A database contains a PRODUCTS table that includes the columns PRODNUM and 
TIMESTAMP_SHIPPED (which allows null). Example 4-1 on page 4-21 selects data 
from the PRODUCTS table and then tests for null by using the indicator variable SHIP-
IND. If the value of the indicator variable is less than 0 (zero), the associated column 
contains a null value.










