更新日期:2024年09月11日
dectolong() 函数将 decimal 类型数值转换为 int4 类型数值。
语法
mint dectolong(dec_val, lng_val)
dec_t *dec_val;
int4 *lng_val;
dec_val
指向 dectolong() 将其值转换为 int4 整数的 decimal 结构的指针。
lng_val
指向 dectolong() 放置转换的结果处的 int4 整数的指针。
返回代码
0
转换成功。
-1200
decimal 类型数值的大小大于 2,147,483,647。
示例
demo 目录中的文件 dectolong.ec 包含下列样例程序。
/*
* dectolong.ec *
The following program converts two DECIMAL numbers to longs and displays the return
value and the result for each conversion.
*/
#include
EXEC SQL include decimal;
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 667 -
char string1[] = "2147483647";
char string2[] = "2147483648";
main()
{
int x;
long n = 0;
dec_t num;
printf("DECTOLONG Sample ESQL Program running.\n\n");
printf("String 1 = %s\n", string1);
if (x = deccvasc(string1, strlen(string1), #))
{
printf(" Error %d in converting string1 to DECIMAL\n", x);
exit(1);
}
if (x = dectolong(#, &n))
printf(" Error %d in converting DECIMAL1 to long\n", x);
else
printf(" Result = %ld\n", n);
printf("\nString 2 = %s\n", string2);
if (x = deccvasc(string2, strlen(string2), #))
{
printf(" Error %d in converting string2 to DECIMAL\n", x);
exit(1);
}
if (x = dectolong(#, &n))
printf(" Error %d in converting DECIMAL2 to long\n", x);
else
printf(" Result = %ld\n", n);
GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 668 -
printf("\nDECTOLONG Sample Program over.\n\n");
exit(0);
}
输出
DECTOLONG Sample ESQL Program running.
String 1 = 2147483647
Result = 2147483647
String 2 = 2147483648
Error -1200 in converting DECIMAL2 to long
DECTOLONG Sample Program over.
执行计划部分主要内容与查询计划一致,同时增加了一些其它属性,如下表:
表5- 143 具体属性如下:
属性
含义
isQueryFinalStep
是否查询步骤的最后一步
DestType
目标类型:1 为所有节点,2 为汇总节点,3 为某个节点
(说明使用该目标表的SQL 全部使用复制表)其它没有
使用
isProducer
是否生产者:0 不是,1 是
isConsumer
是否消费者:0 不是,1 是
producerDistID
生产者ditribution ID
consumerDistID
消费者distribution ID
isSingleHashNode
是否单节点HASH 优化,0 不是,1 是
isHashRedist
是否HASH 重分布步骤,0 不是,1 是
Hash Redist Indexes
HASH 重分布的表达式下标
isGroupHashRedist
未使用
isAllTableAreHashTmpDis
t
是否所有源表都是HASH 重分布临时表。0 不是,1 是
isExistsHashReditTable
是否源表中存在HASH 重分布临时表。0 不是,1 是
queryString
该步骤的SQL
targetTable
目标表
targetSchema
目标表建表语句
[Step] DropList
该步骤执行完后可以删除的临时表列表