问答题 某cc表数据如下: c1 c2 1 西 1 安 1 的 2 天 2 气 3 好 转换为 1 西安的 2 天气 3 好 要求:不能改变表结构及数据内容,仅在最后通过SELECT语句显示出这个查询结果。
【正确答案】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;
【答案解析】