SQL/MP Programming Manual for C
Host Variables
HP NonStop SQL/MP Programming Manual for C—429847-008
2-3
Using Corresponding SQL and C Data Types
Using Corresponding SQL and C Data Types 
Table 2-1 and Table 2-2 on page 2-4 list the corresponding SQL and C data types. 
Table 2-1. Corresponding SQL and C Character Data Types
SQL/MP Data Type C Data Type
Fixed-Length Character Data Type **
hostvar CHAR(l) 
hostvar PIC X(l) 
char hostvar [l + 1]
* 
Fixed-Length Character Data Type With CHARACTER SET Clause 
hostvar CHARACTER (l) 
 CHARACTER SET charset
hostvar PIC X(l) 
 CHARACTER SET charset 
char CHARACTER SET charset hostvar [l 
+ 1]
* 
Fixed-Length Character Data Type With NATIONAL CHARACTER Clause 
hostvar NATIONAL CHARACTER 
(l) 
char CHARACTER SET 
 charset hostvar [l + 1]
* 
Variable-Length Character Data Type **
hostvar VARCHAR(l) struct { 
 short len; 
 char val [l + 1];
* 
} hostvar ;
Variable-Length Character Data Type With CHARACTER SET Clause
hostvar VARCHAR (l) 
 CHARACTER SET charset 
struct { 
 short len; 
 char CHARACTER SET 
 charset val [l + 1];
*
} hostvar ;
Variable-Length Character Data Type With NATIONAL CHARACTER Clause
hostvar NATIONAL CHARACTER 
 VARYING(l) 
struct { 
 short 
len; 
 ch
ar CHARACTER SET 
 defcharset val [l + 1];
*
} hostvar ;
hostvar  A host variable name; hostvar must follow the naming conventions for a C identifier.
l  A positive integer that represents the length in characters of the host variable. 
len, val  The length and value of the host variable. 
charset  One of these character-set keywords: KANJI, KSC5601, ISO8859n, 
where n is 1 – 9, or UNKNOWN (a single-byte unknown character set). 
defcharset  The system default multibyte character set; defcharset is KANJI, unless it is otherwise set 
or changed during system generation. 
*
An extra byte is generated as a place holder for a null terminator.
**
If a character set is not specified, the character set is UNKNOWN.










