--
-- $Id$
--
-- Customer specific once-script YASK#66930.SQL.
-- Dit script zet het kenmerk factuurstatus op 'Gefactureerd' (key=2) voor
-- meldingen die de status Historie hebben.
DEFINE thisfile = 'YASK#66930.SQL'
DEFINE dbuser   = '^YASK'

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

DECLARE
    CURSOR c IS
        SELECT mld_melding_key, FLX.getflex ('MLD', 1, mld_melding_key)     factuurstatus
          FROM mld_melding
         WHERE mld_melding_status = 6;
BEGIN
    FOR rec IN c
    LOOP
        IF rec.factuurstatus = 1
        THEN
            FLX.setflex ('MLD',
                         1,
                         rec.mld_melding_key,
                         2);
        END IF;
    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
