Variables used in SQL commands in an executable section are
known as host variables. All host variables used in a
program must be declared in a declaration part.
In a subprogram, the host variables must be declared in the
declaration section of any level of a procedure -- but not in the global
declaration part.
The host variable declarations must appear between the two
following SQL commands:
EXEC SQL BEGIN DECLARE SECTION;
.
. Host variables are declared here
. in Pascal data declarations.
EXEC SQL END DECLARE SECTION;
|
In Figure 3-1, host variable declarations start at 2.
You can put only one such declaration section in
a program, and all host variables must be declared
between the BEGIN/END DECLARE SECTION commands in a declaration part.
The SELECT command shown at 8 in Figure 3-1
uses three host variables
for data, one for each of the columns in the
PurchDB.Parts table. When used in an embedded SQL command,
host variables are preceded with a colon, as follows:
:PartNumber
:PartName
:SalesPrice
|
For detailed information regarding host variables, see the chapter, "Host Variables."