SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL663854-002
3-27
Numeric Data
add_define =_MX_ARLIB_BIGNUM_FORMAT class=MAP
file=\$dummy.dummy.BINARY
If the DEFINE is set to a value which is not valid, it is ignored and the binary format is
used as the presentation type.
Storing C Character Arrays Into SQL Numeric Columns
You can use C character arrays as host variables in a C program when inserting or
updating values into numeric columns.
When you use char arrays as host variables for NUMERIC, DECIMAL, or PICTURE
9’s columns, use the SQL/MX CAST function to convert the value:
Format a C character string, without the null terminator, consisting of a sign, digits,
and a decimal point. The formatted C character string must be left-justified and
padded with blanks within the character array.
Within an INSERT or UPDATE statement, use the SQL/MX CAST function to
convert the character data to the desired SQL data type. The character set string
can be associated with either ISO88591 or UCS2 character set.
Assigning Numeric Data to Corresponding Data Types
You can perform C arithmetic operations on SQL columns of NUMERIC, PICTURE 9’s,
or DECIMAL data type. To do so, assign the data to host variables with the same data
type as the database data type (that is, NUMERIC, PICTURE 9’s, or DECIMAL) as
shown in Table 3-1 on page 3-8.
Table 3-5 lists the extended SQL C data types NUMERIC and PICTURE 9’s COMP.
Use NUMERIC or PICTURE 9’s COMP host variables within your C program as
shown.
Table 3-6 also lists the extended SQL C data types DECIMAL and PICTURE 9’s
DISPLAY. Use DECIMAL or PICTURE 9’s DISPLAY host variables within your C
program as shown in Table 3-6.
Table 3-5. Host Variable Usage for NUMERIC or PICTURE 9’s COMP Data
C Program Usage NUMERIC or PICTURE 9’s COMP Data
short The length l (the precision) is 1 through 4 digits.
long The length l (the precision) is 5 through 9 digits.
long long The length l (the precision) is 10 through 18 digits.