--
-- $Id$
--
-- Verwijder alle glas melding (srtdisc 141) van 29-09 en ouder

DEFINE thisfile = 'ASDL#41925.SQL'
DEFINE dbuser   = '^ASDL'
DEFINE custid   = 'ASDL'

SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
WHENEVER SQLERROR EXIT;
SELECT adm.scriptspoolfile('&dbuser', '&thisfile') AS fcltlogfile FROM DUAL;
WHENEVER SQLERROR CONTINUE;
SPOOL &fcltlogfile
SET DEFINE OFF

------ payload begin ------

DELETE FROM mld_melding
      WHERE mld_melding_key IN
                  (SELECT mld_melding_key
                     FROM mld_melding m, mld_stdmelding std, mld_discipline d
                    WHERE m.mld_stdmelding_key = std.mld_stdmelding_key
                          AND std.mld_ins_discipline_key =
                                d.ins_discipline_key
                          AND d.ins_srtdiscipline_key = 141
                          AND TRUNC (mld_melding_datum) <=
                                TO_DATE ('29-09-2017', 'DD-MM-YYYY'));

------ payload end   ------

SET DEFINE OFF
BEGIN adm.systrackscriptId ('$Id$', 1); END;
/

COMMIT;
SET ECHO OFF
SPOOL OFF
SET DEFINE ON
PROMPT Logfile of this upgrade is: &fcltlogfile