--
-- Recreate script van Facilitor
--
/*
 * C-style comment is removed from the result
 */
#include "modules.h"
#include "comsql.h"

SET TERMOUT ON
SET FEEDBACK OFF
SET ECHO OFF
SET PAGESIZE 0
SPOOL OFF
SET HEADING OFF
PROMPT ***********************************************************************
PROMPT
PROMPT RECREATE SCRIPT van Facilitor
PROMPT $Revision$
PROMPT $Id$
PROMPT
PROMPT Re-creeert alle algemene views, triggers etc van Faciltor schema _DBV
PROMPT
PROMPT Het wordt aangeraden om deze upgrade te draaien op een moment dat er
PROMPT geen gebruikers bezig zijn met de applicatie.
PROMPT
PROMPT De recreate wordt uitgevoerd. Even geduld a.u.b...
PROMPT

SET TERMOUT ON
SET HEADING OFF
SET FEEDBACK ON
SET ECHO ON
SET VERIFY OFF
SET LINESIZE 1000
SET TIME ON
SET SERVEROUTPUT ON;
SET DEFINE ON
column fcltlogfile new_value fcltlogfile NOPRINT;
select 'RECRE'||_DBV_STRING || '_' || UPPER(USER || '_' || sys_context('USERENV', 'SERVICE_NAME') || '_' || sys_context('USERENV', 'SERVER_HOST')) || '_' || to_char(sysdate,'YYYYMMDD_HH24MISS') || '.lst' as fcltlogfile from dual;
spool &fcltlogfile
SET DEFINE OFF

variable recreate_start number
exec :recreate_start := dbms_utility.get_time

/* first compile all views, triggers etc */
BEGIN DBMS_UTILITY.COMPILE_SCHEMA(USER, FALSE); END;
/
PROMPT List of all invalid objects *before* FACILITOR upgrade.
SELECT 'OR'||'A-'||'DB'||_DBV_STRING||' Warning: ' || object_type || ' ' || object_name || ' was ' || status || ' before the upgrade.'
  FROM user_objects
 WHERE object_type IN ('VIEW', 'TRIGGER', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'PACKAGE BODY')
   AND status <> 'VALID'
 ORDER BY object_name;

#include "recreate.inc"

select 'Recreate has '||'completed in ' || ROUND(( dbms_utility.get_time - :recreate_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:
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 ON
REGISTERONCE('$Id$')

SPOOL OFF
SET ECHO OFF
SET DEFINE ON
PROMPT Recreate is done. Check &fcltlogfile
