--
-- $Id$
--
-- Corrigeren RES_RSV_RUIMTE_PRIJS bij laatste K2F-doorbelasting.
DEFINE thisfile = 'DENB#56634.SQL'
DEFINE dbuser   = '^DENB'

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

ALTER TRIGGER RES_T_RES_RSV_RUIMTE_B_IU DISABLE;

UPDATE res_rsv_ruimte rrr
   SET rrr.res_rsv_ruimte_prijs = rrr.res_rsv_ruimte_prijs + res_rsv_ruimte_korting
 WHERE rrr.res_ruimte_opstel_key IS NOT NULL
       AND rrr.res_rsv_ruimte_prijs IS NOT NULL
       AND rrr.res_rsv_ruimte_korting IS NOT NULL
       AND EXISTS
             (SELECT 1
                FROM denb_v_bbs_res_all
               WHERE TO_CHAR (resver, 'ddmmyyyy') = '22022019'
                     AND res_rsv_ruimte_key = rrr.res_rsv_ruimte_key);

ALTER TRIGGER RES_T_RES_RSV_RUIMTE_B_IU ENABLE;

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