返回首页

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

更新日期:2024年09月11日

bycmpr() 函数比较两组给定长度的相邻字节。它返回比较的结果作为它的值。
语法
mint bycmpr(byte1, byte2, length)
char *byte1;
char *byte2;
mint length;
byte1
指向第一组相邻字节起始位置的指针。

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 611 -
byte2
指向第二组相邻字节起始位置的指针。
length
您想要 bycmpr() 比较的字节数。

用法
bycmpr() 执行对两组相邻字节的逐字节比较,直到它发现不同为止,或直到它比较字
节的 length 数目为止。bycmpr() 函数返回整数,其值(0、-1 或 +1)指示两组字节之间
比较的结果。

bycmpr() 函数从 byte1 组的字节减去 byte2 组的字节来完成比较。

返回代码
0
两个组相同。
-1
byte1 组小于 byte2 组。
+1
byte1 组大于 byte2 组。
示例
此样例程序位于 demo 目录中的 bycmpr.ec 文件中。
/*
* bycmpr.ec *

The following program performs three different byte comparisons with bycmpr() and
displays the results.
*/

#include

main()
{
mint x;

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

static char string1[] = "abcdef";
static char string2[] = "abcdeg";

static mint number1 = 12345;
static mint number2 = 12367;

static char string3[] = {0x00, 0x07, 0x45, 0x32, 0x00};
static char string4[] = {0x00, 0x07, 0x45, 0x31, 0x00};

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

/* strings */
printf("Comparing strings: String 1=%s\tString 2=%s\n", string1, string2);
printf(" Executing: bycmpr(string1, string2, sizeof(string1))\n");
x = bycmpr(string1, string2, sizeof(string1));
printf(" Result = %d\n", x);

/* ints */
printf("Comparing numbers: Number 1=%d\tNumber 2=%d\n", number1, number2);
printf(" Executing: bycmpr( (char *) &number1, (char *) &number2, ");
printf("sizeof(number1))\n");
x = bycmpr( (char *) &number1, (char *) &number2, sizeof(number1));
printf(" Result = %d\n", x);

/* non printable */
printf("Comparing strings with non-printable characters:\n");
printf(" Octal string 1=%o\tOctal string 2=%o\n", string3, string4);
printf(" Executing: bycmpr(string3, string4, sizeof(string3))\n");
x = bycmpr(string3, string4, sizeof(string3));
printf(" Result = %d\n", x);

/* bytes */

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 613 -
printf("Comparing bytes: Byte string 1=%c%c\tByte string 2=%c%c\n");
printf(" Executing: bycmpr(&string1[2], &string2[2], 2)\n");
x = bycmpr(&string1[2], &string2[2], 2);
printf(" Result = %d\n", x);

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

Comparing strings: String1=abcdef String 2=abcdeg
Executing: bycmpr(string1, string2, sizeof(string1))
Result = -1
Comparing numbers: Number 1=12345 Number 2=12367
Executing: bycmpr( (char *) &number1, (char *) &number2, sizeof(number1)
Result = -1
Comparing strings with non-printable characters:
Octal string 1=40300 Octal string 2=40310
Executing: bycmpr(string3, string4, sizeof(string3))
Result = 1
Comparing bytes: Byte string 1=cd Byte string 2=cd
Executing: bycmpr(&string1[2], &string2[2], 2)
Result = 0

BYCMPR Sample ESQL Program over.

|
+-------------------------------+
1 row in set
gbase> SELECT TO_CHAR(2008032001,'c9.99EEEE') FROM dual;
+---------------------------------+
| TO_CHAR(2008032001,'c9.99EEEE') |
+---------------------------------+
|
$2.01E+09
|
+---------------------------------+
1 row in set
示例9:FORMAT 的值为“FM90.9”,删除“10.3”开头和结尾处的空格。
gbase> SELECT TO_CHAR(10.3,'FM90.9') FROM dual;
+-------------------------+
| TO_CHAR(-10.3,'FM90.9') |
+-------------------------+
| 10.3
|
+-------------------------+
1 row in set
gbase> SELECT TO_CHAR(10.3,'90.9') FROM dual;
+----------------------+
| TO_CHAR(10.3,'90.9') |
+----------------------+
|

语法说明

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
921
删除全文索引之后,对应的全文索引内容也会被删除,将不能再使用全文索引进
行查询。
GBase 8a MPP Cluster 提供两种删除全文索引的语法:

DROP INDEX 句法删除全文索引

ALTER TABLE…DROP INDEX 句法删除全文索引