# Oracle循环语句参考示例

--备份错误数据
create table bms_batch_def_noprice0714 as(
select *
  from bms_batch_def t
 where nvl(t.unitprice, 0) = 0
   and t.createfrom = 7);
--修改错误数据
begin
  for c1 in (select *
   from bms_batch_def t
  where nvl(t.unitprice, 0) = 0
    and t.createfrom = 7) loop
    update bms_batch_def a
 set (a.notaxsuprice, a.unitprice) =
     (select b.notaxsuprice, b.unitprice
  from bms_batch_def b
 where b.batchid = c1.oldbatchid)
     where a.batchid = c1.batchid;
  end loop;
end;