-- ABS-34733
-------------   DBCONSISTENCYCHECK   ---------------------
UPDATE DBCONSISTENCYCHECK DB
   SET DB.SQLSTATEMENT = 'select 
cust.defaultbusinessunit_id,
sdl1.timestamp,
cust.customernumber,
       dep.departmentnumber,
       dip.distributionpointnumber,
       p.code                       productcode,
       s.code                       sizecode,
       fm.code                      finishingmethodcode,
       sdl1.standarddeliveryline_id,
       sdl1.dateactive,
       sdl1.dateinactive,
       sdl2.standarddeliveryline_id,
       sdl2.dateactive,
       sdl2.dateinactive
  from standarddeliveryline       sdl1,
       standarddeliveryline       sdl2,
       productlistperdistribpoint plpdp,
       product                    p,
       sizedefinition             s,
       finishingmethod            fm,
       distributionpoint          dip,
       department                 dep,
       customer                   cust
 where sdl1.standarddelivery_id = sdl2.standarddelivery_id
   and sdl1.productlistperdistribpoint_id =
       sdl2.productlistperdistribpoint_id
   and sdl1.standarddeliveryline_id < sdl2.standarddeliveryline_id
   and (((sdl1.dateactive <= sdl2.dateactive) and
       (sdl2.dateactive <= sdl1.dateinactive)) or
       ((sdl2.dateactive <= sdl1.dateactive) and
       (sdl1.dateactive <= sdl2.dateinactive)))
   and sdl1.productlistperdistribpoint_id =
       plpdp.productlistperdistribpoint_id
   and plpdp.distributionpoint_id = dip.distributionpoint_id
   and dip.department_id = dep.department_id
   and dep.customer_id = cust.customer_id
   and plpdp.product_id = p.product_id
   and plpdp.sizedefinition_id = s.sizedefinition_id
   and plpdp.finishingmethod_id = fm.finishingmethod_id
   and sdl1.deliveryscheme_id=sdl2.deliveryscheme_id
   and cust.defaultbusinessunit_id = 5
   order by sdl1.timestamp desc'
      
 WHERE DB.DBCONSISTENCYCHECK_ID = 41;
COMMIT;
