/* Formatted on 6-2-2017 12:25:33 (QP5 v5.136.908.31019) */
--
-- $Id$
--
-- <<converteren kenmerkwaarden naar nieuwe kenmerkmeldingen>>

DEFINE thisfile = 'SGGR#39388.SQL'
DEFINE dbuser   = '^SGGR'
DEFINE custid   = 'SGGR'

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

--- Omzetten alle kenmerkwaarden aankomstdatum (833) en vertrekdatum (834) bij hotelaanvragen (stdmelding_key=346)

UPDATE mld_kenmerkmelding k
   SET k.mld_kenmerk_key =
          (CASE
              WHEN k.mld_kenmerk_key = 833 THEN 1381                 --- datum
              WHEN k.mld_kenmerk_key = 834 THEN 1382              --- datum tm
           END)
 WHERE k.mld_kenmerk_key IN (833, 834)
       AND k.mld_melding_key IN (SELECT mld_melding_key
                                   FROM mld_melding m
                                  WHERE m.mld_stdmelding_key = 346);

COMMIT;

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

@@ &custid