--
-- $Id$
--
-- Na import Topdeskmelding naar Facilitor moeten voor elke aanvraag nog de juiste kostenplaats/departement gekoppeld worden

DEFINE thisfile = 'UBRH#55068_6.SQL'
DEFINE dbuser   = '^UBRH'

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

/* Formatted on 31-1-2019 16:54:32 (QP5 v5.318) */
UPDATE mld_melding mm
   SET mm.mld_kosten_klant = 1,
       mm.prs_kostenplaats_key =
           (SELECT pa.prs_kostenplaats_key
              FROM prs_perslid pp, prs_afdeling pa
             WHERE     mm.prs_perslid_key = pp.prs_perslid_key
                   AND pp.prs_afdeling_key = pa.prs_afdeling_key)
 WHERE     mm.mld_meldbron_key = 6
       AND mm.mld_kosten_klant IS NULL
       AND mm.prs_kostenplaats_key IS NULL;
            
------ 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
