-- Customer specific once-script XXXX#34001.sql
--
-- Support: +31 53 4800700
--


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



UPDATE prs_bedrijf b
   SET (b.prs_relatietype_key) =
         (SELECT CASE
                 WHEN fud.fac_usrdata_omschr = 'Contracting party'
                 THEN 1  /* Contracting party */
                 ELSE 2  /* Managing agent */
                 END
            FROM prs_kenmerk k,
                 prs_kenmerklink v,
                 fac_usrdata fud
           WHERE v.prs_kenmerk_key = k.prs_kenmerk_key
             AND v.prs_kenmerklink_waarde = fud.fac_usrdata_key
             AND k.prs_kenmerk_niveau = 'B'
             AND k.prs_kenmerk_verwijder IS NULL
             AND (k.prs_srtperslid_key IS NULL)
             AND v.prs_kenmerklink_niveau = 'B'
             AND v.prs_kenmerklink_verwijder IS NULL
             AND v.prs_link_key = b.prs_bedrijf_key
             AND k.prs_kenmerk_key = 5);

COMMIT;


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

COMMIT;
SPOOL OFF
