SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
3-11
Data Conversion
Data Conversion
NonStop SQL/MX performs the conversion between SQL and C data types:
•
When a host variable serves as an input variable (supplies a value to the 
database), NonStop SQL/MX converts the value that the variable contains to a 
compatible SQL data type and then uses the value in the SQL operation. 
•
When a host variable serves as an output variable (receives a value from a 
database), NonStop SQL/MX converts the value to the data type of the host 
variable. 
NonStop SQL/MX supports conversion within numeric types and character types—but 
not between numeric and character types.
Converting Numeric Types 
Values of data types NUMERIC, DECIMAL, PICTURE 9’s, INTEGER, SMALLINT, 
FLOAT, REAL, and DOUBLE PRECISION are numbers and are all mutually 
comparable and mutually assignable. 
VARCHAR(99)CHARACTER 
SET KANJI
**
VARCHAR CHARACTER SET 
IS KANJI a[100]
VARCHAR CHARACTER SET 
IS KANJI a[100 
CHARACTERS]
wchar_t a[100]
VARCHAR(99)CHARACTER 
SET KSC5601
**
VARCHAR CHARACTER SET 
IS KSC5601 a[100]
VARCHAR CHARACTER SET 
IS KSC5601 a[100 
CHARACTERS]
wchar_t a[100]
CHAR(99)CHARACTER SET X NCHAR a[100 
CHARACTERS]
Depends on X (X is the 
value of the system 
default 
NATIONAL_CHARSET)
VARCHAR(99)CHARACTER 
SET X
NCHAR VARYING a[100 
CHARACTERS]
Depends on X
(X is the 
value of the system 
default 
NATIONAL_CHARSET)
Table 3-4. Corresponding SQL, C Host Variable Data Types, and Translated C 
Declarations (page 2 of 2)
SQL Data Type C Host Variable Data Type
Translated C 
Declaration
*  An extra character is generated as a placeholder for a null terminator. The embedded SQL C VARCHAR 
data type is SQL:1999.
** KANJI and KSC5601 character sets can be used only with SQL/MP tables. 










