/* _up/epilogue.inc
 * Epiloog van update script van FACILITOR, to be included in every schema update
 *
 * $Revision$
 * $Id$
 */
COMMIT;

DELETE FROM fac_session WHERE fac_session_expire < SYSDATE - 2;
DELETE FROM aut_client_perslid WHERE aut_client_perslid_login < SYSDATE - 60;
DELETE FROM fac_bookmark WHERE fac_bookmark_expire < SYSDATE - 2;
DELETE FROM web_user_messages WHERE web_user_mess_action_datum < SYSDATE - 60;
DELETE FROM fac_notificatie WHERE fac_notificatie_status=0
      AND fac_notificatie_systeemadres IS NULL;
COMMIT;

-- Dialect/terminologie items die niet meer bestaan
DELETE FROM fac_localeitems
      WHERE fac_localeitems_lcl NOT IN
                  (SELECT fac_locale_xsl_label FROM fac_locale_xsl);

-- Bij een DROP TABLE wordt nogal eens de PURGE vergeten
PURGE RECYCLEBIN;

///////////////////////////// now recreate all views, triggers etc acc to the latest state ///////
#include "recreate.inc"

#ifdef POST_RECREATE
#include POST_RECREATE
#endif

select 'Upgrade has completed in ' || ROUND(( dbms_utility.get_time - :update_start )/100) || ' seconds.' from dual;

/* Report invalid objects, if any */
SET ECHO OFF
SET HEADING OFF
SET LINESIZE 132
PROMPT List of all invalid objects after FACILITOR upgrade.
PROMPT Some errors may resolve by running the customer specific script next.
SELECT 'OR'||'A-'||'DB'||_DBV_STRING||' Warning: ' || object_type || ' ' || object_name || ' is ' || status
  FROM user_objects
 WHERE object_type IN ('VIEW', 'TRIGGER', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'PACKAGE BODY')
   AND status <> 'VALID'
 ORDER BY object_name;

SET ECHO OFF
SET FEEDBACK OFF
PROMPT ======================================================================
SELECT 'Schema FACILITOR@' || USER || ' is now ' || fac.getdbversion() FROM DUAL;
PROMPT
PROMPT Your schema upgrade is ready. Please check the logfile for errors.
PROMPT If in doubt please contact: FACILITOR Helpdesk +31 53 4800 700
SET DEFINE ON
PROMPT Logfile of this upgrade is: &fcltlogfile
SPOOL OFF
