SQL Programming Manual for TAL
Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL—527887-001
7-36
Handling Null Values
answer = 32
answer = 65
answer = 89000
answer = 69000
answer = 68000
answer = 96000
answer = 65000
answer = 3000
answer = 4000
answer = 4100
Example of an Application
In a possible application for statement and cursor host variables, a server could use a
loop to initialize the arrays of statement and cursor host variable names and the array
of statements and to execute the PREPARE and DECLARE CURSOR statements. The
program could then use the cursors as follows:
-- Read $RECEIVE
-- Examine a flag in the request message to determine
-- which cursor to use
CASE flag OF
BEGIN
-- Assign appropriate name to cursor-host-variable
-- according to flag
END;
EXEC SQL OPEN : cursor-host-variable;
-- Loop until SQLCODE = 100:
BEGIN
EXEC SQL FETCH : cursor-host-variable INTO : column
-host-variables;
-- Display column values
END;
EXEC SQL CLOSE : cursor-host-variable;
Handling Null Values
The input and output SQLDA structures have two fields, NULL^INFO and IND^PTR,
that are used for handling null values. Your program accesses these fields in the
SQLVAR array, in the same way in which you access VAR^PTR.
NULL^INFO indicates whether the input parameter or output variable can contain a null
value. If NULL^INFO is 0, IND^PTR has no meaning. If NULL^INFO is less
than 0, your program should access IND^PTR before each access of
VAR^PTR in order to handle null values correctly.
IND^PTR points to a flag that indicates whether the input parameter or output
variable actually is null. If the parameter or output variable is not null, the
VAR^PTR field specifies the value.