SQL Programming Manual for TAL

Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL527887-001
2-12
Using Host Variables
The declaration for the called procedure is:
PROC process^cmd(struc);
STRUCT .struc;
BEGIN
STRING val [0:maxsize-1];
END;
...
BEGIN
EXEC SQL PREPARE dyn^cmd FROM :struc.val;
...
END;
Declaring an Equivalenced Local Structure. Declare the parameter as a STRING
array. In SQL statements that are within the scope of the STRING array's declaration,
refer to the parameter using the STRING array name.
Before the STRING array is passed to a procedure as a parameter, declare a local
structure template with a STRING array as the only field, declare a pointer to that
structure template, and equivalence the pointer to the STRING array that was passed
as the parameter. In SQL statements local to the procedure, refer to the parameter as:
structure-name. field-name
For example, you might make these declarations and references:
STRING .strng[0:maxsize-1];
...
PROC process^cmd(s);
STRING .strng;
BEGIN
STRUCT strng^equiv(*);
BEGIN;
STRING val[0:maxsize-1];
END;
STRING .new^strng(strng^equiv) = strng;
...
EXEC SQL PREPARE new^cmd FROM :new^strng.val;
END;
Using Scaled Numeric Data Items as Host Variables
Use one of these two methods to declare a host variable with scale:
Declare the host variable using FIXED(n) data type, where n is the number of
decimal places to the right of the decimal point.
Declare the host variable with a numeric data type that is compatible with the SQL
column, and then use the SETSCALE function to communicate the scale.