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 COBOL—663854-002
3-20
Numeric Data
, or blank), and the last character is reserved for the null terminator. If the scale is
greater than zero, declare the char array three characters larger than the number
of digits. The extra character is reserved for the decimal point.
Within a SELECT INTO or FETCH statement, use the SQL/MX CAST function in
the select list to convert the numeric value from the database to the CHAR data
type.
Append a null terminator to the output character string before you process it as a
C character string.
See the CAST Specification in the SQL/MX Reference Manual.
Initializing DECIMAL Data Types
When initializing the DECIMAL data type, use this strcpy command, where
host_var is defined as DECIMAL:
strcpy(host_var, " 83445589");
Because the host variable is defined as DECIMAL (8,5), the length is 10 (8+2, minus
one character for the null terminator, which makes it 9).
Initializing NUMERIC Data Types
Initialize NUMERIC data types in your application with an assignment statement. No
strcpy or CAST is needed. NUMERIC types are binary types. In this example, the
value 10 is moved to host_var, which is declared as a long.
EXEC SQL BEGIN DECLARE SECTION;
NUMERIC(7,0) host_var;
EXEC SQL END DECLARE SECTION;
host_var=10;
Initializing BigNum Data Types
You can initialize the BigNum data type with a constant int64 value, either from another
BigNum value or from an ASCII string that represents a BigNum value.
BigNum Data Type
A BigNum value is an array of int16 elements. The last element that contains the sign
is the most significant bit. The BigNum data type is defined as follows:
typedef Int16* BignumExt
BigNum Functions
You can use the following BigNum functions to perform basic operations on a BigNum
Host variable:










