-- Customer specific once-script
--
-- Support: +31 53 4800700
--


SET ECHO ON
SET DEFINE ON
column fcltlogfile new_value fcltlogfile NOPRINT;
select UPPER(USER) || '_AAEN#34613' || to_char(sysdate,'YYYYMMDD_HH24MISS') || '.lst' as fcltlogfile from dual;
spool &fcltlogfile
SET DEFINE OFF


UPDATE prs_bedrijf b
   SET prs_relatietype_key =
          (SELECT prs_relatietype_key
             FROM prs_relatietype rt, prs_kenmerklink kl, fac_usrdata ud
            WHERE prs_kenmerk_key = 5
              AND ud.fac_usrdata_key =
                     fac.safe_to_number (kl.prs_kenmerklink_waarde)
              AND prs_relatietype_omschrijving =
                     DECODE (fac_usrdata_code,
                             'CP', 'Contracting party',
                             'MA', 'Managing agent',
                             'Dummy')
              AND b.prs_bedrijf_key = kl.prs_link_key)
 WHERE COALESCE (prs_bedrijf_intern, 0) = 0 AND prs_relatietype_key IS NULL;
 
UPDATE prs_kenmerk
   SET prs_kenmerk_verwijder = SYSDATE
 WHERE prs_kenmerk_key = 5;

COMMIT;


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

COMMIT;
SPOOL OFF
