--
-- $Id$
--
-- <<Maakt een view aan voor een rapport (verwijderde bezoekersafspraken)>>

DEFINE thisfile = 'YKPN#55423.sql'
DEFINE dbuser   = '^YKPN'
DEFINE custid   = 'YKPN'

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

BEGIN
    fac.initsession ('NL');
END;
/

CREATE OR REPLACE VIEW ykpn_v_rap_bezdel
AS
     SELECT t.fac_tracking_key,
        t.fac_tracking_datum,
        t.fac_srtnotificatie_key,
        t.fac_tracking_refkey,
        t.fac_tracking_oms, 
        t.prs_perslid_key, 
        sn.fac_srtnotificatie_code, 
        p.prs_perslid_naam_full as prs_perslid_naam
    FROM fac_tracking t, fac_srtnotificatie sn, prs_v_perslid_fullnames_all  p
    WHERE  p.prs_perslid_key = t.prs_perslid_key
        AND sn.fac_srtnotificatie_key = t.fac_srtnotificatie_key
        AND SUBSTR (sn.fac_srtnotificatie_code, 1, 3) = 'BEZ'
        AND SUBSTR (UPPER (t.fac_tracking_oms), 1, 22) =
                  'AFSPRAAK IS VERWIJDERD'
   ORDER BY 
        t.fac_tracking_refkey, 
        t.fac_tracking_datum DESC;

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