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 COBOL—663854-005
3-2
C Host Variable Data Types
Example
This example uses host variable declarations in an SQL Declare Section:
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
unsigned NUMERIC (6) ordernum; /* simple variables */
struct employee { /* structure */
unsigned short empnum;
char first_name[16];
char last_name[21];
unsigned short deptnum;
unsigned short jobcode;
} employee_info;
...
int * hvarPointer; /* pointer to numeric data type */
struct employee * empStruct; /* structure pointer */
EXEC SQL END DECLARE SECTION;
C Host Variable Data Types
You must explicitly declare all host variables used in SQL statements. A host variable
used in an SQL statement must be declared in an SQL Declare Section prior to the first
use of the host variable in an SQL statement. Only variables of the types recognized
by the 3GL preprocessor can appear within an SQL Declare Section.
To declare a C host variable, specify one of these data types:
char [char-set] C-identifier [l + 1]
| NCHAR C-identifier [l + 1]
| VARCHAR [char-set] C-identifier [l + 1]
| NCHAR VARYING C-identifier [l + 1]
| {[signed] | unsigned} NUMERIC (p, s)
| PIC[TURE] [S]9(l-s)V9(s) COMP
| {[signed] | unsigned} DECIMAL (l, s)
| PIC[TURE] [S]9(l-s)V9(s)
| {[signed] | unsigned} short
| {[signed] | unsigned} int
| {[signed] | unsigned} long
| long long
| float
| double
| DATE
| TIME [(n)]
| TIMESTAMP [(n)]
| INTERVAL [period1[(n)] | SECOND [(n[,m])]] [TO
period2[(m)]]
C










