/————————–比较集合————————–/
/is null—(嵌套表和变长数组) is empty—(只适用于嵌套表)/
declare
type v_varray_type is table of int ;
v_varr1 v_varray_type := v_varray_type(1,2);
v_varr2 v_varray_type ;
begin
if v_varr1 is empty then
dbms_output.put_line(‘v_varr1未初始化……’);
end if;
if v_varr2 is null then
dbms_output.put_line(‘v_varr2未初始化……’);
end if;
end;
/* = 或 != 计较 只适用于嵌套表 */
declare
type v_varray_type is table of int ;
v_varr1 v_varray_type := v_varray_type(1,2);
v_varr2 v_varray_type := v_varray_type(2,1);
begin
if v_varr1 = v_varr2 then
dbms_output.put_line(‘相等……’);
end if;
if v_varr1 != v_varr2 then
dbms_output.put_line(‘不想动……’);
end if;
end;
/* cardinality 返回嵌套表元素个数 只适用于嵌套表 */
declare
type v_varray_type is table of int ;
v_varr1 v_varray_type := v_varray_type(1,2,4,3,1,2);
begin
dbms_output.put_line(’ v_varr1元素个数……’ || cardinality( v_varr1));
dbms_output.put_line(’ v_varr1元素个数……’ || v_varr1.count);
end;
/* submultiset of 1是否为2的子集 只适用于嵌套表 */
declare
type v_varray_type is table of int ;
v_varr1 v_varray_type := v_varray_type(1,2,4,3,1,2);
v_varr2 v_varray_type := v_varray_type(1,2,4);
begin
if v_varr2 submultiset of v_varr1 then
dbms_output.put_line(‘v_varr2是v_varr1的子集’);
end if;
end;
/* member of 成员是否为嵌套表的元素 只适用于嵌套表 */
declare
type v_varray_type is table of varchar2(10) ;
v_varr1 v_varray_type := v_varray_type(‘lisi’,’lt’,’ly’);
v_num varchar(10):=’lisi’;
begin
if v_num member of v_varr1 then
dbms_output.put_line(‘v_num是v_varr1的元素’);
end if;
end;
/* is a set 嵌套表是否包含重复的值 只适用于嵌套表 */
declare
type v_varray_type is table of varchar2(10) ;
v_varr1 v_varray_type := v_varray_type(‘lisi’,’lt’,’ly’);
begin
if v_varr1 is a set then
dbms_output.put_line(‘v_varr1没有重复值……’);
else
dbms_output.put_line(‘v_varr1存在重复值……’);
end if;
end;