SET ECHO ON
SPOOL xnmms#32004.lst
SET DEFINE OFF

ALTER TABLE nmms_monitoring ADD (prs_bedrijf_naam VARCHAR2(60), nmm_melding NUMBER(1));

UPDATE nmms_monitoring mo
   SET prs_bedrijf_naam =
          (SELECT prs_bedrijf_naam
             FROM prs_bedrijf b,
                  prs_afdeling a,
                  prs_perslid p,
                  mld_melding m
            WHERE mo.melding_key = m.mld_melding_key
              AND m.prs_perslid_key = p.prs_perslid_key
              AND p.prs_afdeling_key = a.prs_afdeling_key
              AND a.prs_bedrijf_key = b.prs_bedrijf_key)
 WHERE omschrijving IS NOT NULL;

UPDATE nmms_monitoring mo
   SET nmm_melding =
          (SELECT DECODE (a.prs_bedrijf_key, 1542, 1, 0) nmm_melding
             FROM prs_afdeling a, prs_perslid p, mld_melding m
            WHERE mo.melding_key = m.mld_melding_key
              AND m.prs_perslid_key = p.prs_perslid_key
              AND p.prs_afdeling_key = a.prs_afdeling_key)
 WHERE omschrijving IS NOT NULL;

DELETE fac_usrrap_cols WHERE fac_usrrap_key = 421;

BEGIN adm.systrackscriptid('$Id$'); END;
/

COMMIT;
SPOOL OFF
