-- Customer specific once-script UWVA#25594.
--
-- (c) 2013 SG|facilitor bv
-- $Revision$
-- $Id$
--
-- Support: +31 53 4800700
SET ECHO ON
SPOOL xuwva#25594.lst
SET DEFINE OFF

SELECT   *
           FROM   cnt_v_aanwezigcontract c, prs_perslid p
          WHERE       c.ins_discipline_key = 360               -- Abonnementen
                  AND c.cnt_contract_status = 0              -- NIET Gesloten!
                  AND COALESCE (c.cnt_contract_verlenging, 0) IN (0, 1)
                  AND c.cnt_contract_looptijd_tot >= SYSDATE
                  AND NOT EXISTS -- Beschouw alleen laatste versie van contracten
                        (SELECT   1
                           FROM   cnt_v_aanwezigcontract
                          WHERE   cnt_contract_nummer_intern =
                                     c.cnt_contract_nummer_intern
                                  AND cnt_contract_versie >
                                        c.cnt_contract_versie)
                                        AND c.prs_perslid_key_eig = p.prs_perslid_key
                                        AND (p.prs_perslid_naam like 'INACTIEF%' OR (p.prs_perslid_oslogin IS NULL AND p.prs_perslid_oslogin2 IS NULL));

COMMIT;

BEGIN adm.systrackscript('$Workfile: uwva#25567.sql $', '$Revision$', 1); END;
/
COMMIT;
SPOOL OFF
