返回首页

gbase数据、南大通用产品文档:GBase8a全文索引查询语法

更新日期:2024年09月11日

概述
全文检索主要应用于文本匹配、互联网搜索引擎和信息检索等领域,例如,短信
中查询敏感词汇,过滤垃圾短信,互联网上关键词搜索,智能排序等应用场景,
都涉及到对文本内容的查询。查询时可查询单个词,也可查询多个词,并且多个
词还可使用逻辑运算操作符组合查询,在进行查询之前首先需要了解词、词序和
词距的概念。

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
930

rdefmtdate() 函数使用格式化掩码来将字符串转换为内部的 DATE 格式。

语法
mint rdefmtdate(jdate, fmtstring, inbuf)
int4 *jdate;

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 854 -
char *fmtstring;
char *inbuf;
jdate
指向接收 inbuf 字符串的内部 DATE 值的 int4 整数值的指针。
fmtstring
指向包含要使用 inbuf 字符串的的格式化掩码的缓冲区的指针。
inbuf
指向包含要转换的日期字符串的缓冲区的指针。
用法
rdefmtdate() 函数的 fmtstring 参数指向日期格式化掩码,其包含描述
如何解释该日期字符串的格式。

input 字符串和 fmtstring 必须以相同的月份、日期和年份的序列顺序。然而,它们不
需要包含相同的文字,或月份、日期和年份的相同表示。

在 fmtstring 中,您可包括 weekday 格式(ww),但数据库服务器忽略该格式。inbuf
中没有与 weekday 格式对应的内容。

下列 fmtstring 与 input 的组合是有效的。
格式化掩码输入
mmddyy
Dec. 25th, 2007
mmddyyyy
Dec. 25th, 2007
mmm. dd. yyyy
dec 25 2007
mmm. dd. yyyy
DEC-25-2007
mmm. dd. yyyy
122507
mmm. dd. yyyy
12/25/07
yy/mm/dd

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 855 -
07/12/25
yy/mm/dd
2007, December 25
yy/mm/dd
In the year 2007, the month of December, it is the 25th day
dd-mm-yy
This 25th day of December 2007

如果存储在 inbuf 中的值是四位年份。则 rdefmtdate() 函数使用那个值。如果存储在
inbuf 中的值是两位年份,
则 rdefmtdate() 函数使用 DBCENTURY 环境变量的值来确定要
使用哪个世纪。如果您未设置 DBCENTURY,则 GBase 8s ESQL/C 使用 20 世纪。

返回代码
如果您使用无效的日期字符串格式,则 rdefmtdate() 返回错误代码,并将该内部的
DATE 设置为当前日期。下列为可能的返回代码。
0
操作成功。
-1204
*input 参数指定无效的年份。
-1205
*input 参数指定无效的月份。
-1206
*input 参数指定无效的日期。
-1209
由于 *input 不包含年份、月份和日期之间的定界符,则 *input 的长度必须恰好为 6
或 8 字节。
-1212
*fmtstring 未指定年份、月份和日期。

示例
demo 目录在 rdefmtdate.ec 文件中包含此样例程序。
/*
* rdefmtdate.ec *

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

The following program accepts a date entered from the console, converts it into the internal
date format using rdefmtdate(). It checks the conversion by finding the day of the week.
*/

#include

main()
{
mint x;
char date[20];
int4 i_date;
char *day_name;

static char fmtstr[9] = "mmddyyyy";

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

printf("Enter a date as a single string, month.day.year\n");
gets(date);

printf("\nThe date string is %s.\n", date);

if (x = rdefmtdate(&i_date, fmtstr, date))
printf("Error %d on rdefmtdate conversion\n", x);
else
{
/* Figure out what day of the week i_date is */
switch (rdayofweek(i_date))
{
case 0: day_name = "Sunday";
break;
case 1: day_name = "Monday";

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 857 -
break;
case 2: day_name = "Tuesday";
break;
case 3: day_name = "Wednesday";
break;
case 4: day_name = "Thursday";
break;
case 5: day_name = "Friday";
break;
case 6: day_name = "Saturday";
break;
}
printf("\nThe day of the week is %s.\n", day_name);
}

printf("\nRDEFMTDATE Sample Program over.\n\n");
}
输出
RDEFMTDATE Sample ESQL Program running.

Enter a date as a single string, month.day.year
080894

The date string is 080894
The day of the week is Monday.
RDEFMTDATE Sample Program over.

参数说明:控制继承语义。用来控制继承表的访问策略,off 表示各种命令不能访问子
表,即默认使用ONLY 关键字。这是为了兼容旧版本而设置的。
该参数属于USERSET 类型参数,请参考表GUC 参数设置方式中对应设置方法进行设
置。
取值范围:布尔型

on 表示可以访问子表。

off 表示不访问子表。
默认值:on