Declare float host variables
When you use the C float data type (for SMALLFLOAT
values), be aware that most C compilers pass float to a function
as the double data type. If you declare the function argument
as a float, you might receive an incorrect result. For example,
in the following excerpt, :hostvar might produce an incorrect
value in tab1, depending on how your C compiler handles the float data
type when your program passes it as an argument.
main()
{
double dbl_val;
EXEC SQL connect to 'mydb';
ins_tab(dbl_val);
;
}
ins_tab(hostvar)
EXEC SQL BEGIN DECLARE SECTION;
PARAMETER double hostvar;
EXEC SQL END DECLARE SECTION;
{
EXEC SQL insert into tab1 values (:hostvar, ...);
}
For more information about the SQL floating point data types, see the HCL OneDB™ Guide to SQL: Reference