--
-- $Id$
--
-- Bug in view voor Sentido-koppeling verhelpen

DEFINE thisfile = 'MNNL#39047.SQL'
DEFINE dbuser   = '^MNNL'
DEFINE custid   = 'MNNL'

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

CREATE OR REPLACE VIEW mnnl_v_api_sentido
AS
   SELECT TO_CHAR(rr.res_rsv_ruimte_van, 'YYYYMMDD-HH24MI')||TO_CHAR(rr.res_rsv_ruimte_tot, ',YYYYMMDD-HH24MI') srt,
          rr.res_reservering_key||'/'||rr.res_rsv_ruimte_volgnr nummer,
          TO_CHAR(rr.res_rsv_ruimte_van, 'YYYY-MM-DD HH24:MI:SS') van,
          TO_CHAR(rr.res_rsv_ruimte_tot, 'YYYY-MM-DD HH24:MI:SS') tot,
          rr.res_rsv_ruimte_omschrijving omschrijving,
          pf.prs_perslid_naam_full host,
          TRIM(r.res_ruimte_nr) ruimte,
          r.res_ruimte_key ruimte_key
     FROM res_rsv_ruimte rr,
          res_ruimte_opstelling ro,
          res_ruimte r,
          prs_v_perslid_fullnames pf
    WHERE ro.res_ruimte_opstel_key = rr.res_ruimte_opstel_key
      AND r.res_ruimte_key = ro.res_ruimte_key
      AND pf.prs_perslid_key = rr.res_rsv_ruimte_host_key
      AND rr.res_rsv_ruimte_verwijder IS NULL
      AND rr.res_status_fo_key NOT IN (3, 4)
      AND COALESCE(rr.res_rsv_ruimte_bezoekers_shown, rr.res_rsv_ruimte_noshow) IS NULL
      AND TRUNC(rr.res_rsv_ruimte_van) BETWEEN TRUNC(SYSDATE)
                                           AND TRUNC(SYSDATE+3);

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