EasyManua.ls Logo

HP NonStop SQL/MP

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Introduction
HP NonStop SQL/MP Programming Manual for C429847-008
1-2
Declaring and Using Host Variables
Declaring and Using Host Variables
A host variable is a C variable with a data type that corresponds to an SQL data type.
You use host variables to provide communication between C and SQL statements and
to receive data from a database or to insert data into a database.
You declare host variables in a Declare Section in the variable declarations part of your
program. A Declare Section begins with the BEGIN DECLARE SECTION directive and
ends with the END DECLARE SECTION directive. In this example, host_variable1,
host_variable2, number and name are host variables.
EXEC SQL BEGIN DECLARE SECTION;
int host_variable1; /* int host variable */
char host_variable2[19]; /* char host variable */
struct host_variable_names
{
long number; /* long host variable */
char name[31]; /* char host variable */
} hv_names;
...
EXEC SQL END DECLARE SECTION;
The C compiler accepts the CHARACTER SET clause in a host-variable declaration to
associate a single-byte or double-byte character set such as Kanji or KSC5601 with a
host variable.
When you specify a host variable in an SQL statement, precede the host variable
name with a colon (:). In C statements, you do not need the colon, as shown:
EXEC SQL SELECT column1 INTO :host_variable1 FROM =table
WHERE column1 > :host_variable2;
strcpy(new_name, host_variable1);
For more information, see Section 2, Host Variables.

Table of Contents

Related product manuals