--
-- $Id$
--
-- Herstel alg_locatie_key bij afspraken die met API2 zijn gemuteerd
--
DEFINE thisfile = 'UWVA#85553.SQL'
DEFINE dbuser   = '^UWVA'

SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
COLUMN fcltcusterr NEW_VALUE fcltcusterr NOPRINT;
WHENEVER SQLERROR CONTINUE;
SELECT adm.getscriptspoolfile('&thisfile') AS fcltlogfile FROM DUAL;
SPOOL &fcltlogfile
WHENEVER SQLERROR EXIT;
SELECT adm.checkscriptcust('&dbuser') AS fcltcusterr FROM DUAL;
WHENEVER SQLERROR CONTINUE;
PROMPT &fcltcusterr
SET DEFINE OFF

------ payload begin ------

BEGIN
    FOR cres IN (SELECT res_rsv_ruimte_key
                   FROM bez_afspraak
                  WHERE alg_locatie_key IS NULL
                    AND res_rsv_ruimte_key IS NOT NULL)
    LOOP
        res.follow_afspraak (cres.res_rsv_ruimte_key, 0); -- 0=alleen datum (was wel goed) en alg_locatie_key
    END LOOP;
END;
/

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