-- Script containing customer specific database cleaning up sql statements for CONN 
-- (c) 2007 Facilitor/Dijkoraad IT bv 
-- $Revision: 1 $ 
-- $Modtime: 22-05-07 10:10 $
--
-- Support: +31 53 4800700

set echo on;
SPOOL CONN#12737.LST

-- Verwijderen van de volgende "schade-gerelateerde" opdrachttypen en alle opdrachten+kenmerken van deze typen:
-- 85,86,90,241,242,243,244,245,246,247
-- Dit betreft data in de tabellen:
-- mld_kenmerkopdr, mld_opdr, mld_kenmerk, mld_typeopdr en mld_typeopdr_srtdiscipline
-- De meldingen, die aan de betreffende opdrachten ten grondslag liggen, blijven wel bewaard.

DELETE FROM mld_kenmerkopdr
      WHERE mld_kenmerkopdr_key IN (
               SELECT ko.mld_kenmerkopdr_key
                 FROM mld_kenmerkopdr ko, mld_opdr o
                WHERE ko.mld_opdr_key = o.mld_opdr_key
                  AND o.mld_typeopdr_key IN (85,86,90,241,242,243,244,245,246,247));

DELETE FROM mld_opdr o
      WHERE o.mld_typeopdr_key IN (85,86,90,241,242,243,244,245,246,247);

DELETE FROM mld_kenmerk k
      WHERE k.mld_typeopdr_key IN (85,86,90,241,242,243,244,245,246,247);
 
DELETE FROM mld_typeopdr t
      WHERE t.mld_typeopdr_key IN (85,86,90,241,242,243,244,245,246,247);
 
DELETE FROM mld_typeopdr_srtdiscipline ts
      WHERE ts.mld_typeopdr_key IN (85,86,90,241,242,243,244,245,246,247);

COMMIT;
SPOOL OFF;
