返回首页

gbase数据、南大通用产品文档:GBase8s

更新日期:2024年09月11日

Row must contain data
Array.getAttributes() 或 Array.getAttributes(Map) 方法返回 0 元素,
这些方法必须返回一个非
零数。

维持空闲连接数 ...................................
35

ifx_int8cvdec() 函数将 decimal 类型值转换为 int8 类型值。
语法
mint ifx_int8cvdec(dec_val, int8_val)

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 728 -
dec_t *dec_val;
ifx_int8_t *int8_val;
dec_val
指向 ifx_int8cvdec() 转换为 int8 类型值的 decimal 结构的指针。
int8_val
指向 ifx_int8cvdec() 放置转换的结果处的 int8 结构的指针。

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

示例
demo 目录中的文件 int8cdec.ec 包含下列样例程序。
/*
* ifx_int8cvdec.ec *

The following program converts two INT8s types to DECIMALS and displays the results.
*/

#include

EXEC SQL include decimal;
EXEC SQL include "int8.h";

char string1[] = "2949.3829398204382";
char string2[] = "3238299493";
char result[41];

main()
{

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 729 -
mint x;
ifx_int8_t n;
dec_t num;

printf("IFX_INT8CVDEC Sample ESQL Program running.\n\n");

if (x = deccvasc(string1, strlen(string1), #))
{
printf("Error %d in converting string1 to DECIMAL\n", x);
exit(1);
}
if (x = ifx_int8cvdec(#, &n))
{
printf("Error %d in converting DECIMAL1 to INT8\n", x);
exit(1);
}

/* Convert the INT8 to ascii and display it. Note that the digits to the right of the decimal
are truncated in the conversion.
*/

if (x = ifx_int8soasc(&n, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf("String 1 Value = %s\n", string1);
printf(" INT8 type value = %s\n", result);
if (x = deccvasc(string2, strlen(string2), #))
{
printf("Error %d in converting string2 to DECIMAL\n", x);
exit(1);

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 730 -
}
if (x = ifx_int8cvdec(#, &n))
{
printf("Error %d in converting DECIMAL2 to INT8\n", x);
exit(1);
}
printf("String 2 = %s\n", string2);

/* Convert the INT8 to ascii to display value. */

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

printf("\nIFX_INT8CVDEC Sample Program over.\n\n");
exit(0);
}
输出
IFX_INT8CVDEC Sample ESQL Program running.

String 1 Value = 2949.3829398204382
INT8 type value = 2949
String 2 = 3238299493
INT8 type value = 3238299493
IFX_INT8CVDEC Sample Program over.