SQL Programming Manual for Pascal
HP NonStop SQL Programming Manual for Pascal—528614-001
2-1
2 Host Variables and Parameters
This section describes host variables and parameters, two mechanisms that provide
communication between Pascal and SQL statements in a Pascal program.
Host Variables
A host variable is a data item you can use in both Pascal and SQL statements to
provide communication between the two types of statements.
For static SQL programs, a host variable can be an input or output variable (or both in
some cases). An input variable transfers data from the program to the database; an
output variable transfers data from the database to the program. (For dynamic SQL
programs, input parameters and output variables fulfill the same function as input and
output host variables in static SQL programs).
A host variable can be one of the following:
•
Simple variable
•
Element of an array
•
Field of a record
•
SQL object referenced by a pointer
However, a host variable cannot be any of the following:
•
Subarray
•
Record
•
File
•
Set
•
Pointer
•
Enumeration
•
Variable of type BYTE, BOOLEAN, CONDITION_CODE,WORDADDR,
BYTEADDR, or EXTADDR
A host variable can be any Pascal data item that has a corresponding SQL data type
as shown in Table 2-1 on page 2-3. NonStop SQL must be able to convert the data
between the two data types. If your program returns a Pascal assignment expression
to a host variable, the Pascal compiler must be able to convert the value of the
expression to the data type of the host variable.
Declaring Host Variables
You declare host variables in a Declare Section in the variable declarations of your
program. You can use multiple Declare Sections in a Pascal program, but you cannot