SQL/MX 3.1 Programming Manual for C and COBOL (H06.23+, J06.12+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.1 Programming Manual for C and COBOL663854-001
3-22
Numeric Data
the application must use binary_64_s=1237000. The scale is implicit and must
be handled in the application.
int main()
{
Exec sql set catalog 'ework';
Exec sql set schema 'ework';
SQLCODE = -1;
memset(SQLSTATE, 32, 6);
strncpy(insert_buf, " ", sizeof(insert_buf));
strcpy(insert_buf, "INSERT INTO tb32 (binary_64_s) VALUES
(cast(? as numeric(18, 3)));");
EXEC SQL PREPARE ins FROM :insert_buf;
printf("SQLCODE after PREPARE ins is %d\n", SQLCODE);
binary_64_s = 1273;
ia = 0;
EXEC SQL EXECUTE ins USING :binary_64_s indicator :ia;
printf("SQLCODE after insert - 3 is %d\n", SQLCODE);
EXEC SQL COMMIT WORK;
printf("\nSQLCODE after COMMIT WORK is %d\n\n", SQLCODE);
return 0;
Assigning Floating-Point Data Types
A column in an SQL/MX format table declared with a floating-point data type is stored
in IEEE floating-point format, and all computations on it are done assuming that. In
addition, all computations performed in MXCI, either on SQL/MX or SQL/MP tables,
use IEEE floating-point format.
A column in an SQL/MP format table declared with a floating-point data type is stored
in Tandem floating-point format, and all computations on it are done assuming that.
NonStop SQL/MX provides an option to store SQL/MP floating-point data in host
variables in IEEE floating-point format. The difference between IEEE and Tandem
floating-point format is seen in the storage, precision, and implementation for the
formats. Input and output via host variables can be treated as IEEE or Tandem floating-
point format.
If you use NonStop SQL/MX to perform computations on a floating-point column in an
SQL/MP table, the result is in IEEE format.
For dynamic queries in embedded SQL programs, the default is Tandem floating-point
format.