SQL/MP Programming Manual for C
Host Variables
HP NonStop SQL/MP Programming Manual for C—429847-008
2-4
Using Corresponding SQL and C Data Types
Table 2-2. Corresponding SQL and C Numeric, Date-Time, and INTERVAL Data
Types
SQL/MP Data Type C Data Type
Numeric Data Types
NUMERIC (1 to 4,s) SIGNED short
NUMERIC (1 to 4,s) UNSIGNED unsigned short
NUMERIC (5 to 9,s) SIGNED long
NUMERIC (5 to 9,s) UNSIGNED unsigned long
NUMERIC (10 to 18,s) SIGNED long long
PIC 9(l-s)V9(s) COMP Same as NUMERIC
DECIMAL (l, s) decimal[l + 1]
**
PIC 9(l-s)V9(s) decimal[l + 1]
**
SMALLINT SIGNED short
SMALLINT UNSIGNED unsigned short
INTEGER SIGNED long
INTEGER UNSIGNED unsigned long
LARGEINT SIGNED long long
FLOAT (1 to 22 bits) float
REAL float
FLOAT (23 to 54 bits) double
DOUBLE PRECISION double
Date-Time and INTERVAL Data Types
DATETIME, TIMESTAMP, DATE, TIME char[l + 1]
*
INTERVAL char[l + 1]
***
l A positive integer that represents the length. For DECIMAL, l must range from 1 – 18.
s A positive integer that represents the scale of the number.
*
An extra byte is generated as a place holder for a null terminator.
**
The decimal data type is normally used to declare an array that can hold all the digit characters, the
sign, and, optionally, a null terminator. The size of the array should be no more than 20 (19 plus an
extra byte for the null terminator), or 21 (20 plus an extra byte for the null terminator) if a separate
sign is used
.
***
An INTERVAL data type has an extra byte for a sign.