游标查询语句中没有条件? 那就可以不这么写了. 直接update....避免 :)
在update的子查询需要用多少时间呢? 大概有多少条记录呢?

解决方案 »

  1.   

    dm_depot 表北遍历了两次,2万条记录就不是2万了,
    可以调试一下永别的方法来替代,
      

  2.   

    begin
      update dm_depot t
         set t.status = (select bill_type
                           from (select bill_type
                                   from tmp_depot_bill
                                  where project_no = t.project_no and
                                        product_name = t.product_name and
                                        year_no = t.year_no and
                                        batch_no = t.batch_no and
                                        serial_no = t.serial_no
                                  order by operate_time desc)
                          where rownum <= 1)
       where exists
       (select 1
                from dm_depot v
               where t.project_no = v.project_no and
                     t.product_name = v.productname_no and t.year_no = v.year_no and
                     t.batch_no = v.batch_no and t.serial_no = v.serial_no);  commit;end;