【正确答案】create or replace function x return
varchar2
is
type t_array is table of number index by binary_integer;
type tarray is table of varchar2(10) index by binary_integer;
ta t_array;
tar tarray;
re varchar2(10);
n number;
na varchar2(10);
begin
select id bulk collect into ta from (select id,name from xx order by id) group by id;
for i in ta.First..ta.last loop
dbms_output.put(ta(i)||'');
select name bulk collect into tar from xx where id=ta(i);
for i in tar.first..tar.last loop
dbms_output.put(tar(i));
end loop;
dbms_output.put_line('');
end loop;
return re;
end;