只有写一个过程或函数了
然后用动态SQL

解决方案 »

  1.   

    execute immediate '........'||变量||;
      

  2.   

    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;
    /