--
-- $Id$
--
-- Sluit alle openstaande opdrachten van afgemelde meldingen
-- Key 6 = afgemeld
-- Key 4 = Gefiatteerd, Key 5 = Toegekend, Key 8 = Geaccepteerd
-- Key 1 = Afgewezen, Key 5 = Afgemeld, Key 6 = Historie

DEFINE thisfile = 'SKAF#41455.SQL'
DEFINE dbuser   = '^SKAF'
DEFINE custid   = 'SKAF'

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 mld_opdr
   SET mld_statusopdr_key = 6
 WHERE mld_opdr_key IN
             (SELECT mld_opdr_key
                FROM mld_opdr o, mld_melding m
               WHERE     mld_statusopdr_key IN (4, 5, 8)
                     AND m.mld_melding_key = o.mld_melding_key
                     AND m.mld_melding_status IN (1, 5, 6));

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