1

我有两个 Oracle refcursors 一个包含行列表(CustomersList),另一个包含每行的列名(PriceGroups)。我需要遍历每一行和每一列并更新每一行/列的交集。如何重新定位列光标以一次又一次地从第一列开始。该表如下所示

Customer   | pricegroupA | priceGroupB | priceGroupC | priceGroupEtc|
-----------+---------------------------------------------------------
aaaa       | 23.5        | 23.8        | 30.9        | 41.3         |
---------------------------------------------------------------------
bbbb       | 21.7        | 24.6        | 49.9        | 45.9         |
---------------------------------------------------------------------
....
4

1 回答 1

2

如果您共享了一堆代码,我可以为您重写它,但我认为以下示例对您有所帮助。

declare
  type r_cursor is REF CURSOR;
  c_emp r_cursor;
  en emp.ename%type;
begin
   /*Opening the refCursor for the first time*/
   open c_emp for select ename from emp;
  loop
      fetch c_emp into en;
      exit when c_emp%notfound;
      dbms_output.put_line(en);
  end loop;
  /*Closing it*/  
  close c_emp;
 /*Opening the refCursor again after it is closed*/
  open c_emp for select ename from emp;
  loop
      fetch c_emp into en;
      exit when c_emp%notfound;
      dbms_output.put_line(en);
  end loop;
  close c_emp;
  /*Closing it again*/  
end;
于 2012-02-27T00:43:59.930 回答