1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| drop table tmp1;
drop table tmp2;
create table tmp1 (n1 number, pad1 varchar2(40));
create table tmp2 (n2 number, pad2 varchar2(40));
insert into tmp1 values (1,'x');
insert into tmp1 values (2,'x');
insert into tmp1 values (3,'x');
insert into tmp1 values (4,'x');
insert into tmp1 values (5,'x');
insert into tmp1 values (6,'x');
insert into tmp2 values (1,'y');
insert into tmp2 values (3,'y');
insert into tmp2 values (5,'y');
insert into tmp2 values (7,'y');
commit;
create or replace type tmp_type1 as object (n1 number, pad1 varchar2(40));
/
create or replace type tmp_type2 as object (n2 number, pad2 varchar2(40));
/
declare
type tmp_type1_tt is table of tmp_type1;
type tmp_type2_tt is table of tmp_type2;
a1 tmp_type1_tt;
a2 tmp_type2_tt;
begin
select tmp_type1(tmp1.n1,tmp1.pad1),tmp_type2(tmp2.n2,tmp2.pad2) bulk collect into a1,a2 from tmp1,tmp2 where n1=n2;
dbms_output.put_line(a1.count||' '||a2.count);
for i in a1.first..a1.last loop
dbms_output.put_line(a1(i).n1||': '||a1(i).pad1);
end loop;
dbms_output.put_line('.');
for i in a2.first..a2.last loop
dbms_output.put_line(a2(i).n2||': '||a2(i).pad2);
end loop;
end; |
Partager