SQL Programming Manual for TAL
Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL—527887-001
7-11
Overview of a Dynamic SQL Program
If you know the number and data type of your input parameter values, you can 
simply set DATA^TYPE, DATA^LEN, and VAR^PTR.
Some programs might check DATA^TYPE and DATA^LEN again when the 
actual values are obtained.
•
If you are handling null values, check NULL^INFO and continue as follows 
according to its value:
0 Do not allocate memory. However, for the best results, set IND^PTR to an 
invalid address, such as %HFFFC0000%D, as shown in the example on page 
7-18
.
-1 Allocate 2 bytes of memory for the indicator variable and set IND^PTR to 
point to the memory allocated in the previous step. (If you are not allocating 
memory dynamically, define a variable for the indicator and put its address in 
IND^PTR.)
6. Loop through the names buffer to read the corresponding name for each 
parameter and prompt the user for each value. Read each value into the data 
buffer you have allocated for the corresponding parameter, according to the data 
type of the value. If the parameter can be null (NULL^INFO is -1) and the value 
entered was null, set the indicator variable at the location in IND^PTR to -1.
Handling the Output Variables
Perform these steps if sqlsa.PREPARE.OUTPUT^NUM is greater than 0 (zero).
1. Get the length of the output names buffer from 
sqlsa.PREPARE.OUTPUT^NAMES^LEN
2. Call ALLOCATE^SQLDA to allocate memory for the output SQLDA (and output 
names buffer, if needed). GETPOOL returns a pointer to the SQLDA in 
OSQLDA^PTR.
3. Initialize the SQLDA header fields (SQLDA^EYE^CATCHER is defined by the TAL 
compiler):
OSQLDA^PTR.EYE^CATCHER ':=' SQLDA^EYE^CATCHER;
OSQLDA^PTR.NUM^ENTRIES := sqlsa.PREPARE.OUTPUT^NUM;
4. Issue a DESCRIBE statement to access the output variables:
! Using a statement name:
EXEC SQL DESCRIBE s1
 INTO :osqlda^ptr
 NAMES INTO :onamebuf^ptr.namestr;
! Using a statement host variable:
EXEC SQL DESCRIBE :statement^hostvar
 INTO :osqlda^ptr
 NAMES INTO :onamebuf^ptr.namestr;










