我现在在存储过程中使用游标取出几万条记录集,然后打开游标,对每条记录作处理,
平均每条记录要处理1秒钟,这样导致报错ora-01555 snapshot too old,我现在想通过把记录集取到一个变量集合里,然后对变量集合的每个记录作处理,
但不知道这个变量集合怎么定义,怎么取数据,请高手指教!

解决方案 »

  1.   

    type collect_type is table of 表名%rowtype
    index by binary_integercollect collect_type;
    查询的时候就
    select *  bulk collect into collect from XXX然后对集合collect操作咯
      

  2.   

    能不能再具体点,怎么对集合collect操作呢?
      

  3.   


    for i in 1..collect1.count loop
       这时候collect1就相当一个2维数组了
       collect1(i).字段名  这样调用
       做你要的操作咯
    end loop;
      

  4.   

    1楼对。但要ORACLE 10以后的版本
      

  5.   

    type t_rec is record(
        a  table.a%TYPE
    )
    type t_t is table of t_rec index by binary_integer;
    l_t       t_t;
    SQL_AREA:='select a from table';
    execute immediate SQL_AREA
    bulk collect into l_t;for i in 1..l_t.count loop
         取得l_t[i].a;
    end loop;貌似用动态的sql能快一些