SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
3-15
Specifying Host Variables in SQL Statements
Example
The following example shows that you cannot declare a character data type as a host
variable:
EXEC SQL BEGIN DECLARE SECTION;
/* cannot declare a character type pointer as host variable */
char * charPtr;
...
This is an illegal construct and returns the following warnings when compiled:
Hewlett-Packard NonStop(TM) SQL/MX C/C++ Preprocessor 3.2.1
(c) Copyright 2003, 2004-2013 Hewlett-Packard Development
Company, LP.
*** WARNING[13029] Pointer or Reference types not supported for
Host Variables.
*** WARNING[13025] Warning(s) near line 5.
The following example shows the use of character data type in a structure:
EXEC SQL BEGIN DECLARE SECTION;
struct ptrType
{
/* all data types are allowed as structure fields */
char charField[100];
...
};
struct ptrType * structPtr;
...
Specifying Host Variables in SQL Statements
Use host language naming conventions for your host variable and indicator variable
names. For example, a name in a C program contains alphanumeric characters,
including the underscore (_), and begins with a letter or an underscore. To avoid
conflicts with system-generated names, do not begin your host variable names with
underscores.
After you declare a host variable, to specify it within an embedded SQL statement, use
this syntax:
variable-name
is the host variable name. It can be any valid host language identifier with a data
type that corresponds to an SQL data type. You must precede variable-name
with a colon (:) within an SQL statement.
:variable-name [[INDICATOR] :indicator_variable]