create or replace procedure TestJiaoJi
is
type nt_table_type is table of number;
nt1 nt_table_type:=nt_table_type(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
nt2 nt_table_type:=nt_table_type(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
result nt_table_type;
iTotalNum integer:=0;--记录交集个数,不包括0
begin
for n in 1..5
loop
nt1(n) :=n;
nt2(n) :=n+2;
end loop;
result:=nt1 multiset intersect nt2;--求交集
dbms_output.put_line('交集是:');
for i in 1..result.count
loop
if(result(i)!=0) then
iTotalNum:=iTotalNum+1;
dbms_output.put_line(''||result(i));
end if;
end loop;
if result.count>0 then
dbms_output.put_line('包括0在内的元素个数为:'||result.count);
end if;
if iTotalNum>0 then
dbms_output.put_line('不包括0在内的元素个数为:'||iTotalNum);
end if;
--dbms_output.new_line;
end TestJiaoJi;