返回首页

gbase数据、南大通用产品文档:GBase8sifx_int8cvflt() 函数

更新日期:2024年09月11日

ifx_int8cvflt() 函数将 C float 类型数值转换为 int8 类型数值。
语法

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 731 -
mint ifx_int8cvflt(flt_val, int8_val)
double flt_val;
ifx_int8_t *int8_val;
flt_val
ifx_int8cvflt() 要将其转换为 int8 类型值的 float 值。
int8_val
指向 ifx_int8cvflt() 放置转换的结果处的 int8 结构的指针。

返回代码
0
转换成功。
<0
转换失败。

示例
demo 目录中的文件 int8cvflt.ec 包含下列样例程序。
/*
* ifx_int8cvflt.ec *
The following program converts two floats to INT8 types and displays the results.
*/

#include

EXEC SQL include "int8.h";

char result[41];

main()
{
mint x;
ifx_int8_t num;


GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 732 -
printf("IFX_INT8CVFLT Sample ESQL Program running.\n\n");

printf("Float 1 = 12944.321\n");

/* Note that in the following conversion, the digits to the right of the decimal are ignored.
*/

if (x = ifx_int8cvflt(12944.321, #))
{
printf("Error %d in converting float1 to INT8\n", x);
exit(1);
}

/* Convert int8 to ascii to display value. */

if (x = ifx_int8soasc(#, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" The INT8 type value is = %s\n", result);
printf("Float 2 = -33.43\n");

/* Note that in the following conversion, the digits to the right of the decimal are ignored.
*/

if (x = ifx_int8cvflt(-33.43, #))
{
printf("Error %d in converting float2 to INT8\n", x);
exit(1);
}
if (x = ifx_int8soasc(#, result, sizeof(result)))

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 733 -
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" The second INT8 type value is = %s\n", result);

printf("\nIFX_INT8CVFLT Sample Program over.\n\n");
exit(0);
}
输出

IFX_INT8CVFLT Sample ESQL Program running.

Float 1 = 12944.321
The INT8 type value is = 12944
Float 2 = -33.43
The second INT8 type value is = -33
IFX_INT8CVFLT Sample Program over.

有些应用程序要求有动态地组合 SQL 语句的能力,以响应用户输入。例如,程序可能必
须选择不同的列或将不同的标准应用到行,这依赖于用户想要什么。
使用动态的 SQL,程序在内存中将 SQL 语句组合成字符串,并将它传递给数据库服务器
来执行。
动态的语句不是代码的一部分;
在执行期间在内存中构造它们。
要了解更多信息,
请参阅 动态 SQL。


GBase 8s SQL 指南:教程
南大通用数据技术股份有限公司
- 206 -

gbase_stmt_fetch_column ......................
59