我声明了一个数组,不知怎样取出数组的值,操作表的字段
cursor c_test is select * from tbl_test;
 TYPE myarray IS TABLE OF c_test%ROWTYPE;
 cur_array myarray;
begin
          open c_test;
          loop
              fetch c_test bulk collect into cur_array limit 100000;
              exit when c_flight_info%notfound;
              怎样取出数组里面的值呀?
           
          end loop;
          close c_flight_info;
      exception
         when others then
         raise_application_error(-20199,'处理数据出错!');
         return;
      end;另外limit参数的作用是什么?,我的表中有10W条记录需要处理

解决方案 »

  1.   


    --给你个例子:
    declare
       type ename_table_type is table of emp.ename%type ;--index by binary_integer;
       type sal_table_type is table of emp.sal%type; --index by binary_integer;
       ename_table ename_table_type;
       sal_table sal_table_type:=sal_table_type();
       sql_stat varchar2(200);
    begin
         ename_table:=ename_table_type('SCOTT','SMITH','ALLEN');
         sql_stat:='update emp set sal=sal*1.1 where ename=:1 returning sal into :2';
         forall i in 1..ename_table.count
                execute immediate sql_stat using ename_table(i) returning bulk collect into sal_table;
         for j in 1..ename_table.count loop
             dbms_output.put_line('雇员:'||ename_table(j)||'的薪水:'||sal_table(j));
         end loop;
    end;
    /    PL/SQL block, executed in 0.454 sec.
        雇员:SCOTT的薪水:3300             
        雇员:SMITH的薪水:880              
        雇员:ALLEN的薪水:1760             
        Total execution time 0.454 sec.     
      

  2.   

    另外 bulk collect中limit参数啥意思?
      

  3.   


    --使用了builk collect into 就不要循环 limit 是取游标中的100000的行数
    declare
    cursor c_test is select * from tbl_test;
     TYPE myarray IS TABLE OF c_test%ROWTYPE;
     cur_array myarray;
    begin
      open c_test;  fetch c_test bulk collect into cur_array limit 100000;
      close c_flight_info;
    for i in 1..cur_array.count loop
    dbms.output.put_line(i.col....);
    end loop;
      exception
      when others then
      raise_application_error(-20199,'处理数据出错!');
      return;
      end;
      

  4.   


    --使用了bulk collect into 就不要循环 limit 是取游标中的100000的行数后面接limit n 就是每次从游标中取n条记录 你的是100000