--
-- $Id$
--
-- Script om de uitvoerdatum van de taken op vorig jaar te zetten. Anders kommen de werkzaamheden op dit jaar te staan.
--
DEFINE thisfile = 'KMMO#75103.sql'
DEFINE dbuser   = '^KMMO'

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

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

UPDATE ins_deelsrtcontrole
   SET ins_deelsrtcontrole_datum = TO_DATE ('20211231 23:59', 'yyyymmdd hh24:mi'),
       ins_deelsrtcontrole_datum_org = TO_DATE ('20211231 23:59', 'yyyymmdd hh24:mi')
 WHERE TO_CHAR (ins_deelsrtcontrole_datum, 'yyyymmdd hh24') = '20221110 14';

UPDATE ins_deelsrtcontrole
   SET ins_deelsrtcontrole_datum = TO_DATE ('20211231 23:59', 'yyyymmdd hh24:mi'),
       ins_deelsrtcontrole_datum_org = TO_DATE ('20211231 23:59', 'yyyymmdd hh24:mi')
 WHERE ins_deelsrtcontrole_key IN
           (SELECT dsc.ins_deelsrtcontrole_key
              FROM ins_deelsrtcontrole  dsc,
                   ins_srtcontrole      sc,
                   ins_tab_discipline   d,
                   ctr_disc_params      dp
             WHERE     dsc.ins_srtcontrole_key = sc.ins_srtcontrole_key
                   AND sc.ctr_discipline_key = d.ins_discipline_key
                   AND d.ins_discipline_key = dp.ctr_ins_discipline_key
                   AND ctr_disc_params_ismjob = 1
                   AND ins_deelsrtcontrole_datum >
                       TO_DATE ('20211231', 'yyyymmdd'));

------ 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
