想用循环还遍历一组无规律的数据,如:
for var in ( 45,23,1544,666,48,24)  loop 
   --do something
end loop;             -----显然这种方法有问题。我知道可以将这些无规律数据写到一张临时表里,然后select出来,但没有权限建表呢???
请问各位大神,有没有其它方法?

解决方案 »

  1.   

    create or replace type item_tab is table of varchar2(2000)--is
    aaa item_tab ;
    cursor c is
    select column_value
    from table(aaa);--begin
    aaa.extend;
    aaa(aaa.count) := 45;
    .
    .
    .for var in c loop  
       --do something
    end loop;
      

  2.   

    不过你没有建表权限,建type的权限也不见得有。
    你直接用数组不行吗,循环数组呗,为什么非要select出来?
      

  3.   


    --Oracle 10g:begin
      for var in (  
          with tab as(
          select '45,23,1544,666,48,24' num from dual
          )
          select regexp_substr(num,'[^,]+',1,level) num from tab
          connect by
          level<=length(num)-length(replace(num,',',''))+1
      )
      loop
        --do something
        dbms_output.put_line(var.num) ;
      
      end loop;
    end;
       PL/SQL block, executed in 0 sec.
       45                              
       23                              
       1544                            
       666                             
       48                              
       24                              
       Total execution time 0.016 sec. 
      

  4.   

    可以借助oracle的对象类型,建立内部类型