--
-- $Id$
--
-- Customer specific once-script BLCC#38826.
DEFINE thisfile = 'BLCC15.SQL'
DEFINE dbuser   = '^BLCC'
DEFINE custid   = 'BLCC'

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

-- De oude soortmeldingen onder vakgroepen < key=420 per 01-01-2017 vervallen,
-- behalve onder vakgroep met key=23 (Algemeen)!
UPDATE mld_stdmelding sm
   SET sm.mld_stdmelding_vervaldatum = TO_DATE ('01-01-2017', 'dd-mm-yyyy'),
       sm.mld_stdmelding_planbaar = 0,
       sm.mld_stdmelding_slabewaken = 1,
       sm.ins_srtinst_verplicht = 0,
       sm.alg_org_obj_niveau = 9,
       sm.mld_stdmelding_freetext = 2, -- Verplicht
       sm.mld_stdmelding_afmeldtext = 1, -- Optioneel
       --sm.mld_stdmelding_doublecheck = 0, -- Niet
       sm.mld_stdmelding_kopieerbaar = 0,
       sm.mld_stdmelding_kto = 0,
       sm.mld_stdmelding_autoorder = 0,
       sm.mld_stdmelding_vereisdienst = 0,
       --sm.mld_stdmelding_opdrtypevast = 0,
       sm.mld_stdmelding_directklaar = 0
 WHERE     sm.mld_stdmelding_verwijder IS NULL
       AND sm.mld_stdmelding_vervaldatum IS NULL
       AND sm.mld_ins_discipline_key <> 23 -- Algemeen!
       AND sm.mld_ins_discipline_key < 420;

COMMIT;

-- De nieuw toegevoegde soortmeldingen onder vakgroepen > key=420 configureren!
UPDATE mld_stdmelding sm
   SET sm.mld_stdmelding_planbaar = 0,
       sm.mld_stdmelding_slabewaken = 1,
       sm.ins_srtinst_verplicht = 0,
       sm.alg_org_obj_niveau = 9,
       sm.mld_stdmelding_freetext = 2, -- Verplicht
       sm.mld_stdmelding_afmeldtext = 1, -- Optioneel
       --sm.mld_stdmelding_doublecheck = 0, -- Niet
       sm.mld_stdmelding_kopieerbaar = 0,
       sm.mld_stdmelding_kto = 0,
       sm.mld_stdmelding_autoorder = 0,
       sm.mld_stdmelding_vereisdienst = 0,
       --sm.mld_stdmelding_opdrtypevast = 0,
       sm.mld_stdmelding_directklaar = 0
 WHERE     sm.mld_stdmelding_verwijder IS NULL
       AND sm.mld_stdmelding_vervaldatum IS NULL
       AND sm.mld_ins_discipline_key > 420;

COMMIT;

-- De nieuw toegevoegde vakgroepen > key=420 configureren!
UPDATE mld_disc_params
   SET mld_disc_params_bestellimiet = 3000,
       mld_disc_params_bestellimiet2 = 20000,
       mld_disc_params_bestellimiet3 = 100000,
       mld_disc_params_bestellimiet4 = 100000
 WHERE mld_ins_discipline_key > 420;

COMMIT;

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

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

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

@@&custid
