返回首页

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

更新日期: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.

首字词操作符‘^’
操作符含义
要想查询以某个词开头的信息,可在查询词前面加上^符号,注意^符号与词之间

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
931
不能有空格。例如查询'^南',表示查询以南字开头的信息。
示例
示例:搜索以南大词组开头的短信内容
gbase> SELECT * FROM sms WHERE contains(MB_Text, '^"南大"');
+-----------+--------------------------------------------------+
|no
| text
|
+-----------+--------------------------------------------------+
|13023315123| 南大开设java 编程培训班,每周五晚上7:00-9:00 上课|
|13323315181| 南大通用数据技术股份有限公司地址:...
|
+-----------+--------------------------------------------------+
2 row in set

GBA-02DU-0001
错误码
错误标识
错误信息
GBA-02DU-000
1
ER_GCLUSTER_TA
BLE(全表删除时)
There is no table '%s.%s'
错误出现原因
无法从系统表gbase.table_distribution 中找到表'%s.%s'的信息
分析与建议
1.
请检查该表是否为express 引擎表;
2.
请检查gbase.table_distribution 表中是否记录该表信息,信息是否正确;若
无,向gbase.table_distribution 表中插入该表信息;