--
-- $Id$
--
-- <<Korte omschrijving wat het script doet>>

DEFINE thisfile = 'TWYN1.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 ------
CREATE TABLE twyn_bgtlog
(
   volgnr    NUMBER(10),
   actie     VARCHAR2(20),
   loglevel  VARCHAR2(3),
   datum     DATE,
   msg       VARCHAR2(2000),
   disc_key  NUMBER(10) DEFAULT NULL,
   prj_key   NUMBER(10) DEFAULT NULL,
   rub_key   NUMBER(10) DEFAULT NULL,
   grp_key   NUMBER(10) DEFAULT NULL,
   srt_key   NUMBER(10) DEFAULT NULL,
   bgt_key   NUMBER(10) DEFAULT NULL,
   mut_key   NUMBER(10) DEFAULT NULL,
   opdr_key  NUMBER(10) DEFAULT NULL,
   fact_key  NUMBER(10) DEFAULT NULL,
   bedr_key  NUMBER(10) DEFAULT NULL,
   kpls_key  NUMBER(10) DEFAULT NULL,
   kgrp_key  NUMBER(10) DEFAULT NULL
);

UPDATE fac_usrrap_cols
   SET fac_usrrap_cols_filter = 'A'
 WHERE fac_usrrap_cols_key IN
(
 SELECT c.fac_usrrap_cols_key
   FROM fac_usrrap r
      , fac_usrrap_cols c
  WHERE r.fac_usrrap_key = c.fac_usrrap_key
    AND r.fac_usrrap_omschrijving IN ('CONT_ALF', 'CON_ACC', 'MMW_CONT', 'MMW_INVCO')
    AND LOWER(fac_usrrap_cols_column_name) IN ('opdrachtgever', 'project','subproject')
);

UPDATE fac_usrrap_cols
   SET fac_usrrap_cols_filter = 'E'
 WHERE fac_usrrap_cols_column_name = 'versienummer';

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