SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL—663854-005
3-14
Data Conversion
NonStop SQL/MX converts data between signed and unsigned numeric types and
between numeric types with different precisions. Note that if a signed numeric type has
a negative value, it cannot be converted.
If assignment would result in a loss of significant digits, NonStop SQL/MX returns a
data exception condition in SQLSTATE. For a description of SQLSTATE values, see
Table 13-1 on page 13-2.
Converting Character Types
Values of data types CHARACTER, PICTURE X’s, and CHARACTER VARYING are
character strings and are all mutually comparable and mutually assignable if both are
of the same character set. In addition, UCS2 host variables are mutually comparable
and assignable with ISO88591 nonhost variable objects.
For character strings of different lengths, NonStop SQL/MX pads the receiving string
variable on the right with blanks as necessary.
If the receiving string variable is too short, NonStop SQL/MX truncates the right part of
the string retrieved from the database and returns a data exception condition in
SQLSTATE. For a description of SQLSTATE values, see Table 13-1 on page 13-2.
Host Variable Pointers
The following types of pointers can be declared as host variables:
Pointer to a structure.
Pointer to a binary fixed-point numeric host variable.
Pointer to a floating-point numeric host variable.
Do not declare the following data type host variables as pointers:
Character
Decimal numeric
Date-time or interval data
If you need to access a host variable with any of these data types through a pointer,
you must make the pointer a structure field.
Note. For optimal performance, declare host variables with corresponding data types and the
same lengths as their respective columns in SQL statements (with consideration for the extra
character required for the null terminator). This programming practice minimizes the data
conversion performed by NonStop SQL/MX and therefore can improve the performance of your
program.










