--
-- $Id$
--
-- Corrigeer de verkeerde indexering van 4 januari in de freeze

DEFINE thisfile = 'PCHW#56022.sql'
DEFINE dbuser   = 'PCHW'


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

UPDATE 
pchx_svd
SET index_totaal = index_totaal * PCHX_MON.get_index_value(LAST_DAY(ADD_MONTHS(TRUNC(export_datum, 'MONTH'),-1)), kostensoort)
WHERE TO_CHAR(export_datum, 'DD-MM-YYYY') = '04-01-2019';

UPDATE 
pchx_monitoring
SET totaal_index = totaal_index * PCHX_MON.get_index_value(LAST_DAY(ADD_MONTHS(TRUNC(export_datum, 'MONTH'),-1)), 'MON')
WHERE TO_CHAR(export_datum, 'DD-MM-YYYY') = '04-01-2019';

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