返回首页

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

更新日期:2024年09月11日

获取AUTO_INCREMENT 列值方法3
......................................... 150

ifx_cl_card() 函数返回指定的集合类型主变量的基数。
语法
mint ifx_cl_card(collp, isnull)
ifx_collection_t *collp;
mint *isnull;
collp
指向应用程序中 collection 主变量的名称的指针。
isnull
如果该集合为空,则设置为 1,否则,设置为 0

用法
ifx_cl_card() 函数使得您能够确定集合中元素的数目、是否为空集合,以及集合是否
为空值。

返回代码
0
空集合。
>0
集合中元素的数目。
<0
发生错误。

示例

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

此样例程序在 demo 目录中的 ifx_cl_card.ec 文件中。
/*
* Check the cardinality of the collection variable when
* the data is returned from the server
*/

main()
{
exec sql begin declare section;
client collection myset;
exec sql end declare section;
mint numelems = 0;
mint isnull = 0;

exec sql allocate collection ::myset;
exec sql create database newdb;
exec sql create table tab (col set(int not null));
exec sql insert into tab values ("set{}");
exec sql select * into :myset from tab;
if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 0)
printf("collection is empty\n");
else if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 1)
printf("collection is null\n");
else if ((numelems = ifx_cl_card(myset, &isnull))> 0)
printf("number of elements is %d\n", numelems);
else
printf("error occurred\n");

exec sql update tab set col = ’set{1,2,3}’;
exec sql select * into :myset from tab;
if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 0)
printf("collection is empty\n");


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

else if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 1)
printf("collection is null\n");
else if ((numelems = ifx_cl_card(myset, &isnull))> 0)
printf("number of elements is %d\n", numelems);
else
printf("error occurred\n");

exec sql update tab set col = NULL;
exec sql select * into :myset from tab;
if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 0)
printf("collection is empty\n");
else if ((ifx_cl_card(myset, &isnull) == 0) && isnull == 1)
printf("collection is null\n");
else if ((numelems = ifx_cl_card(myset, &isnull))> 0)
printf("number of elements is %d\n", numelems);
else
printf("error occurred\n");
}
输出
collection is empty
number of elements is 3
collection is null

取值:[0, INT_MAX]
默认值:3
说明:hdfs 导入导出功能超时后的重试次数,默认3 次。

GBase 8a MPP Cluster 参数手册
文档版本2022-06-07
南大通用数据技术股份有限公司
7
修改方式:全局参数,在配置文件中赋值和修改。