SQL Programming Manual for TAL

Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL527887-001
7-5
Using the SQLDA and Names Buffer
If you do not know in advance which columns to select, you can dynamically compile
the statement, use DESCRIBE to find out which columns are being selected, and then
allocate data buffers to receive the column values. The SQLDA structure contains
pointers to the buffers.
In this case, the FETCH statement would look like this:
EXEC SQL
FETCH cursor
USING DESCRIPTOR : sqlda; ! The SQLDA contains
! pointers to output
! data buffers
Internally, SQL execution is the same for both options.
Using the SQLDA and Names Buffer
To allocate storage for information about input parameters and output variables in a
dynamic SQL statement, the dynamic SQL program declares one or more instances of
the SQLDA and names buffer. The SQLDA holds this information:
The number of input parameters or output variables the SQLDA can accommodate in
the NUM^ENTRIES field For each input parameter or output variable, an SQLVAR
structure with this information:
The DESCRIBE and DESCRIBE INPUT statements set the NULL^INFO field
depending on whether the prepared SQL statement includes a null indicator and not
whether the column actually allows a null value. To determine if a column allows a null
value, check the NULLALLOWED column in the COLUMNS table for the catalog where
the table is registered.
When your program issues a DESCRIBE INPUT or DESCRIBE statement, the system
supplies values for all the fields of the SQLDA except EYE^CATCHER,
NUM^ENTRIES, VAR^PTR, and IND^PTR. Your program must initialize these SQLDA
fields as described in these susbsections.
Field Description
DATA^TYPE Data type (TAL data type literals are shown under Allocating Memory
for the Values. on page 7-20)
DATA^LEN Length and scale or date-time qualifier
PRECISION Leading field precision for a date-time or INTERVAL item, or the
numeric precision for a FLOAT or binary numeric item
NULL^INFO Indicator for whether the item can contain a null value
VAR^PTR Extended address of the input parameter or output variable
IND^PTR Extended address of the associated indicator variable (if it exists)