SQL Programming Manual for Pascal

Using Dynamic SQL
HP NonStop SQL Programming Manual for Pascal528614-001
7-6
Using the SQLDA and Names Buffer
°
An indication of whether the item could contain a null value in the NULL_INFO
field
°
The extended address of the input parameter or output variable in the
VAR_PTR field
°
The extended address of the associated indicator variable in the IND_PTR field
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 follows:
Before DESCRIBE INPUT or DESCRIBE
Set EYE_CATCHER to the constant SQLDA_EYE_CATCHER.
Set NUM_ENTRIES to the number of SQLVAR entries allocated in the SQLDA (the
number of input parameters or output columns expected). If you do not know this
number in advance, you can get it from the INPUT_NUM or OUTPUT_NUM fields
of the SQLSA after the PREPARE statement executes.
After DESCRIBE INPUT or DESCRIBE
Set VAR_PTR to point to the input or output data buffers.
Set IND_PTR to point to any indicator variables. If your program does not process
null values, set IND_PTR to an invalid address such as the one shown in the
detailed dynamic SQL program in Appendix C, Examples of Dynamic NonStop
SQL Programs.
In some cases, your program might change the contents of the DATA_TYPE,
DATA_LEN, or PRECISION fields; for example, when the data type of the input
parameter or output variable you declared is compatible with but not the same as
the data type SQL uses, or when you want to manipulate the scale information in
the first byte of the DATA_LEN field.
For input parameter handling, the FETCH or EXECUTE operation usually references
the same SQLDA structure used for DESCRIBE INPUT. Similarly, for output variable
handling, the FETCH or EXECUTE operation references the same SQLDA structure
used for DESCRIBE.
If the program will execute a statement using input parameters, you declare an SQLDA
to describe the input parameters. If the program will execute a dynamic SELECT
statement or an INSERT statement with the RETURNING LASTSYSKEY option, you
declare a second SQLDA to describe the output variables (SELECT columns or
system-defined primary key).
The names buffer stores the names of the input parameters (after DESCRIBE INPUT)
or the names of selected columns (after DESCRIBE). For an expression, the names
buffer contains a null string. If you will need to prompt the user for parameter values or