返回首页

gbase数据、南大通用产品文档:GBase8aTIME(expr)

更新日期:2024年09月11日

函数说明
将时间部分从time 或者datetime 表达式expr 中取出来,并按照字符串格式返回。
示例
示例1:以字符串格式返回“2020-08-30 01:02:03”中的时间值。
gbase> SELECT TIME('2020-08-30 01:02:03') FROM dual;
+-----------------------------+
| TIME('2020-08-30 01:02:03') |
+-----------------------------+
| 01:02:03
|
+-----------------------------+
1 row in set
示例2:以字符串格式返回“2020-08-30 01:02:03.000123”中的时间值。
gbase> SELECT TIME('2020-08-30 01:02:03.000123') FROM dual;
+------------------------------------+
| TIME('2020-08-30 01:02:03.000123') |

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
812
+------------------------------------+
| 01:02:03.000123
|
+------------------------------------+
1 row in set

ifx_int8tolong() 函数将 int8 类型数值转换为 C long 类型数值。
语法
mint ifx_int8tolong(int8_val, lng_val)
ifx_int8_t *int8_val;
int4 *lng_val;
int8_val

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 767 -

指向 ifx_int8tolong() 将其值转换为 int4 整数类型值的 int8 结构的指针。
lng_val
指向 ifx_int8tolong() 放置转换的结果处的 int4 整数的指针。

返回代码
0
转换成功。
-1200
int8 类型的数值的大小大于 2,147,483,647。

示例

demo 目录中的文件 int8tolong.ec 包含下列样例程序。
/*
* ifx_int8tolong.ec *
The following program converts three strings to INT8 types and converts the INT8 type
values to C long type values.Then the values are displayed.

*/

#include

EXEC SQL include "int8.h";

char string1[] = "-1,555,345,698";
char string2[] = "3,235,635";
char string3[] = "553.24";

main()
{
int x;
long l =0;
ifx_int8_t num1, num2, num3;

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 768 -


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

if (x = ifx_int8cvasc(string1, strlen(string1), &num1))
{
printf("Error %d in converting string1 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string2, strlen(string2), &num2))
{
printf("Error %d in converting string2 to INT8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string3, strlen(string3), &num3))
{
printf("Error %d in converting string3 to INT8\n", x);
exit(1);
}
printf("\nConverting INT8 to long\n");
if (x= ifx_int8tolong(&num1, &l))
{
printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String 1= %s\n", string1);
printf("INT8 value is = %d\n", l);
}

printf("\nConverting second INT8 to long\n");
if (x= ifx_int8tolong(&num2, &l))
{

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 769 -

printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String2 = %s\n", string2);
printf("INT8 value is = %d\n",l);
}
printf("\nConverting third INT8 to long\n");

/* Note that the decimal places will be truncated. */

if (x= ifx_int8tolong(&num3, &l))
{
printf("\tError %d in converting INT8 to long\n", x);
exit(1);
}
else
{
printf("String3 = %s\n", string3);
printf("INT8 value is = %d\n",l);
}
printf("\nIFX_INT8tOLONG Sample Program over.\n\n");
exit(0);
}
输出

IFX_INT8tOLONG Sample ESQL Program running.

Converting INT8 to long

Executing: ifx_int8tolong(&num1,&l)
String 1= -1,555,345,698

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 770 -

The value of the first long is = -1555345698


Converting second INT8 to long

Executing: ifx_int8tolong(&num2, &l)
String2 = 3,235,635
The value of the second long is = 3235635


Converting third INT8 to long

Executing: ifx_int8tolong(&num3, &l)
String3 = 553.24
The value of the third long is = 553
IFX_INT8tOLONG Sample Program over.

07/30/1998
1007