declare str varchar2(100):='select '; type t_sor is ref cursor; v_sor t_sor; begin for i in 0..23 loop str:=str||'acurr'||i||','; end loop; str:=substr(str,1,length(str)-1)||' from table where ...'; open v_sor for str; loop fetch v_sor into 变量; exit when v_sor%notfound; dbms_output.put_line(变量); end loop; close v_sor; end; /
str varchar2(100):='select ';
type t_sor is ref cursor;
v_sor t_sor;
begin
for i in 0..23 loop
str:=str||'acurr'||i||',';
end loop;
str:=substr(str,1,length(str)-1)||' from table where ...';
open v_sor for str;
loop
fetch v_sor into 变量;
exit when v_sor%notfound;
dbms_output.put_line(变量);
end loop;
close v_sor;
end;
/