返回首页

gbase数据、南大通用产品文档:GBase8sEXISTS

更新日期:2024年09月11日

判断可变数组和嵌套表的指定元素是否存在。
EXISTS(n):如果第n个元素存在,存在返回TRUE,否则FALSE。如果n超出了索引范
围,返回false。对于被Delete(n)删除的元素,返回false。
CREATE OR REPLACE PROCEDURE P_5_18 AS
TYPE NumList IS TABLE OF INTEGER;
n NumList := NumList(1,3,5,7);
BEGIN

GBase 8s PL/SQL手册
南大通用数据技术股份有限公司
- 75 -

n.DELETE(2); -- Delete second element
FOR i IN 1..6 LOOP
IF n.EXISTS(i) THEN
DBMS_OUTPUT.PUT_LINE('n(' || i || ') = ' || n(i));
ELSE
DBMS_OUTPUT.PUT_LINE('n(' || i || ') does not exist');
END IF;
END LOOP;
END;

--Result:
--n(1) = 1
--n(2) does not exist
--n(3) = 5
--n(4) = 7
--n(5) does not exist
--n(6) does not exist


GBase 8s 管理员参考
南大通用数据技术股份有限公司 - 25 -

除了用户 gbasedbt 和 DBSA 组成员之外,
ADMIN_MODE_USERS 配置参数指定您想在管理模
式下访问数据库服务器的用户列表。
onconfig.std 值
未设置。只有用户 gbasedbt 和 DBSA 组成员可以在管理模式下访问 GBase 8s 。
分隔符
用逗号分隔用户名,比如:Karin,Sarah,Andrew,字符串最长 127 字节。
生效
编辑 onconfig 文件并重启数据库服务器之后。
当通过运行 onmode -wf 命令来动态地重置 onconfig 文件中的值时。
当通过运行 onmode -wm 命令来重置内存中的值时。
用法
永久保存 ADMIN_MODE_USERS 配置参数中的用户列表。您可以使用 onmode
-wm 或 onmode
-wf 命令来移除用户。
在数据库运行时,使用 onmode -j -U 命令来允许一个或多个用户在管理模式下访问数据
库服务器。
您必须将 ADMIN_USER_MODE_WITH_DBSA 配置参数设置为 1 以使得罗列在
ADMIN_MODE_USERS 配置参数中的用户能够在管理模式下连接到数据库服务器。

ifx_int8cvlong() 函数将 C long 类型值转换为 int8 类型值。
语法
mint ifx_int8cvlong(lng_val, int8_val)
int4 lng_val;
ifx_int8_t *int8_val;
lng_val
ifx_int8cvlong() 将其转换为 int8 类型值的 int4 整数。
int8_val
指向 ifx_int8cvlong() 放置转换的结果处的 int8 结构的指针。

返回代码
0
转换成功。
<0
转换失败。

示例
demo 目录中的文件 int8cvlong.ec 包含下列样例程序。
/*
* ifx_int8cvlong.ec *

The following program converts two longs to INT8
types and displays the results.
*/


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

#include

EXEC SQL include "int8.h";

char result[41];

main()
{
mint x;
ifx_int8_t num;
int4 n;

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

printf("Long Integer 1 = 129449233\n");
if (x = ifx_int8cvlong(129449233L, #))
{
printf("Error %d in converting long to INT8\n", x);
exit(1);
}
if (x = ifx_int8toasc(#, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String for INT8 type value = %s\n", result);

n = 2147483646; /* set n */
printf("Long Integer 2 = %d\n", n);
if (x = ifx_int8cvlong(n, #))
{
printf("Error %d in converting long to INT8\n", x);

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

exit(1);
}
if (x = ifx_int8toasc(#, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" String for INT8 type value = %s\n", result);

printf("\nIFX_INT8CVLONG Sample Program over.\n\n");
exit(0);
}
输出
IFX_INT8CVLONG Sample ESQL Program running.

Long Integer 1 = 129449233
String for INT8 type value = 129449233
Long Integer 2 = 2147483646
String for INT8 type value = 2147483646
IFX_INT8CVLONG Sample Program over.