PROMPT $UPI_TOP/sql/RMINC_run_stat.sql 
PROMPT 
PROMPT Runs          &3..RMINC_stats.sql
PROMPT Which creates report &3

PROMPT Analyze Tables & Indexes (RMINC)

PROMPT Copyright 2000, All Rights Reserved, Reed-Matthews, Inc.
PROMPT
PROMPT Analyzes all the tables that aren't owned by SYS or SYSTEM
PROMPT Although this application uses Rule-based optimization
PROMPT in the init.ora file, there are some places where
PROMPT cost-based optimization is turned on when hints are used in
PROMPT the application code.  Cost-based optimization requires 
PROMPT analyzed data to work correctly.
PROMPT
PROMPT APPS runs this, so APPS must have ANALYZE ANY permission:
PROMPT as user SYS:
PROMPT grant analyze any to apps;
set linesize 180
set pagesize 200
clear buffer
set head off
set termout off
set feedback off
set verify off
-- Following spool will create file like 
--      DHAMILTO.328526.RMINC_stats.sql 
-- in your report output directory. 
-- Note: double period (..) after the variable causes a single period to 
-- come out in the filename.
-- Do not define parameter 3 in the concurrent manager.  The report spool 
-- file is known to the concurrent manager as the last user parameter + 1.
spool &3..RMINC_stats.sql;
-- select 'spool &3..RMINC_statisti.lis' from dual;
select 'whenever sqlerror continue' from dual;
select 'ANALYZE TABLE '||owner||'.'||table_name||' COMPUTE STATISTICS;'
        from all_tables
    where owner not in ('SYS','SYSTEM')
    and owner >= upper('&1') and owner <= upper('&2');
select 'PROMPT ALL DONE' from dual;
--select 'spool off;' from dual;
spool off;
-- Following spool causes output to go to the standard report output file.
spool &3
-- These settings should send information to log file as well as report file.
set echo on
set termout on
set feedback on
@&3..RMINC_stats.sql
-- Remove left over sql file
host rm &3..RMINC_stats.sql
exit;

