SQL Programming Manual for Pascal

Using Dynamic SQL
HP NonStop SQL Programming Manual for Pascal528614-001
7-37
Handling Null Values
indicates a nonnull value, and gets the parameter value from the location VAR_PTR
points to.
Handling Null Values in Output Variables
DESCRIBE sets NULL_INFO to -1 if the output variable can contain a null value—that
is, if the prepared statement included a null indicator. If the value returned is null, SQL
checks NULL_INFO and moves a -1 into the location pointed to by IND_PTR. (Errors
are returned if the value is null but NULL_INFO is 0 or if IND_PTR is an invalid
address.)
Your program must check NULL_INFO to determine whether the value returned could
be null. If NULL_INFO contains a -1, then your program checks the location IND_PTR
points to. If that location contains a -1, then a null value was returned; if the location
contains 0, then a nonnull value was returned and your program should get the value
from the location indicated in VAR_PTR.
Null Values and the Names Buffer
If your program processes indicator parameters, the names of the indicator parameters
are included in the names buffer after DESCRIBE INPUT executes. The IND_PTR field
points to the length field for the parameter name in the names buffer. This behavior is
parallel to that of VAR_PTR after DESCRIBE INPUT or DESCRIBE.
The following diagram illustrates the structure of the names buffer immediately after
DESCRIBE INPUT when indicator parameters are present for two parameters, where
len is a 2-byte length, name is a parameter name, ind- len is the length of an indicator
parameter name, and ind-name is an indicator parameter name. Each instance of
IND_PTR points to the length field for the corresponding indicator parameter name.
Like input parameter and output variable names, indicator variable names are padded
with blanks to even lengths.
Note. Both DESCRIBE INPUT and DESCRIBE set the NULL-INFO field depending on
whether the prepared SQL statement included a null indicator and not on whether the column
in the table allows a null value. To determine if a column allows a null value, check the
NULLALLOWED column in the COLUMN catalog table for the catalog where the table is
registered.
SQLVAR[1]
.VAR_PTR
len1 name1
SQLVAR[1]
.IND_PTR
ind_len1 ind_name1
SQLVAR[2]
.VAR_PTR
len2 name2
SQLVAR[2]
.IND_PTR
ind_len2 ind_name2