SQL Programming Manual for TAL
Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL—527887-001
2-19
Using Indicator Variables for Null Values
Selecting a Null Value
This example selects data from the SHIPMENTS table and tests for null values using
the indicator variable named PROD^REC.SHIP^IND:
! Variable declarations:
EXEC SQL BEGIN DECLARE SECTION;
STRUCT .prod^rec;
BEGIN
INT prodnum;
INT ship^ind;
STRING date^shipped[0:9];
END;
EXEC SQL END DECLARE SECTION;
...
EXEC SQL DECLARE c1 CURSOR FOR
SELECT prodnum, date^shipped
FROM =SHIPMENTS
WHERE prodnum > 7999;
...
! Procedure code:
WHILE sqlcode = 0 DO
BEGIN
EXEC SQL
FETCH c1 INTO
:prod^rec.prodnum,
:prod^rec.date^shipped
INDICATOR :prod^rec.ship^ind;
IF prod^rec.ship^ind < 0 THEN ...
! display "?", "NULL", or other symbol to
! indicate a null value.
END;