-- correction script for todo 11204

update deliveryvariations dv
   set dv.soilcountsubtype = 1
 where dv.origin = 1
   and dv.soilcountsubtype = 0
   and dv.packingnote_id is null
   and dv.updaterentqty = 'Y'
   and not exists
 (select 1
          from deliveryvariations d
         where d.distributionpoint_id = dv.distributionpoint_id
           and d.product_id = dv.product_id
           and d.sizedefinition_id = dv.sizedefinition_id
           and d.finishingmethod_id = dv.finishingmethod_id
           and nvl(d.packingnote_id,-1) = nvl(dv.packingnote_id,-1)
           and d.processed = dv.processed
           and d.deliverydate = dv.deliverydate
           and d.origin = dv.origin
           and nvl(d.causenote_id,-1) = nvl(dv.causenote_id,-1)
           and d.updaterentqty = dv.updaterentqty
           and d.soilcountsubtype = 1);

commit;