SQL Programming Manual for TAL
Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL—527887-001
2-11
Using Host Variables
To use the host variable INDIRECT^STRUCT, specify:
EXEC SQL
SELECT empname INTO :indirect^struct FROM people;
If you make STRUCT^POINTER point to INDIRECT^STRUCT, you can also specify:
EXEC SQL
SELECT empname INTO :struct^pointer FROM people;
Using Arrays as Host Variables
Follow these guidelines when you declare and use arrays as host variables.
The TAL compiler interprets STRING arrays of length [0: size - 1] as one of these SQL
data types:
•
CHAR(size)
•
DECIMAL(size), if you specified overriding the default data type
•
Date-time or INTERVAL, if you used the TYPE AS clause
The size of a STRING array does not have to match the size of the character field in
the VARCHAR column, CHAR column, or the date-time or INTERVAL column.
NonStop SQL pads or truncates the value to fit the host variable. For arrays of a data
type other than STRING, the size of an array element must be compatible with the size
of the SQL column.
Using STRING Parameters as Host Variables
Host variables that are passed as TAL STRING parameters require special
consideration because TAL does not allow you to specify bounds on a parameter
declaration. Use either of these two methods to handle this type of parameter:
•
Declare the parameter as a structure.
•
Declare an equivalenced local structure.
Declaring the Parameter as a Structure. Declare the STRING parameter as a field in
a structure. In SQL statements, always refer to the parameter as:
structure-name.field-name
However, when you pass the parameter, use the structure name (and not the field
name). For example:
STRUCT .struc;
BEGIN
STRING val [0:maxsize-1];
END;