SQL/MP Programming Manual for C
HP NonStop SQL/MP Programming Manual for C—429847-008
2-1
2 Host Variables
A host variable is a data item you can use in both C statements and NonStop SQL/MP 
statements to allow communication between the two types of statements. A host 
variable appears as a C identifier and can be any C data item declared in a Declare 
Section that has a corresponding SQL/MP data type as shown in Table 2-1
 on 
page 2-3 and Table 2-2
 on page 2-4. However, a host variable cannot be the name or 
identifier (the left part) of a #define directive. 
For static SQL operations, a host variable can be an input or an output variable (or 
both in some cases) in an SQL statement. An input host variable transfers data from 
the program to the database, whereas an output host variable transfers data from the 
database to the program. 
(For dynamic SQL operations, input parameters and output variables fulfill the same 
function as input and output host variables in static SQL statements.) 
An indicator variable is a two-byte integer variable, also declared in a Declare Section, 
that is associated with a host variable. An indicator variable indicates whether a 
column contains, or can contain, a null value. A null value means that a value is either 
unknown for the row or does not apply to the row. A program uses an indicator variable 
to insert null values into a database or to test a column value for a null value after 
retrieving the value from a database. 
Topics include:
Specifying a Declare Section
Coding Host Variable Names on page 2-2
Using Corresponding SQL and C Data Types on page 2-3
Specifying Host Variables in SQL Statements on page 2-6
Declaring and Using Host Variables on page 2-7
Using Indicator Variables for Null Values on page 2-17
Creating Host Variables Using the INVOKE Directive on page 2-18
Associating a Character Set With a Host Variable on page 2-24
Specifying a Declare Section 
You declare all host variables in a Declare Section. The BEGIN DECLARE SECTION 
and END DECLARE SECTION directives designate a Declare Section. Follow these 
guidelines when you specify a Declare Section: 
Use the BEGIN DECLARE SECTION and END DECLARE SECTION directives 
only in pairs. 










