--
-- $Id$
--
-- <<bgt_budget_isreserve zetten voor reserve uit geimporteerde subprojecten EPO>>

DEFINE thisfile = 'TWYN#53532.SQL'
DEFINE dbuser   = '^TWYN'

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 bgt_budget
   SET bgt_budget_isreserve = 1
 WHERE bgt_budget_key IN
     ( SELECT bgt_budget_key
         FROM bgt_budget b
            , bgt_kostenrubriek r
        WHERE b.bgt_kostenrubriek_key = r.bgt_kostenrubriek_key
          AND b.prs_kostensoortgrp_key IS NULL
          AND b.bgt_budget_isreserve = 0
          AND r.bgt_kostenrubriek_code = 'R'
     );

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