column report_name new_value report_name noprint;
select 'PMS_'||:inst_num||'_'||to_char(sysdate-1 ,'yyyymmdd')||'_'||:bhour||'-'||:ehour||'.txt' report_name from dual;
begin
declare
id number;
name varchar2(100);
descr varchar2(500);
BEGIN
name := '';
descr := 'ADDM run: snapshots [' || :bid || ', '
|| :eid || '], instance ' || :inst_num
|| ', database id ' || :dbid;
dbms_advisor.create_task('ADDM',id,name,descr,null);
:task_name := name;
dbms_advisor.set_task_parameter(name, 'START_SNAPSHOT', :bid);
dbms_advisor.set_task_parameter(name, 'END_SNAPSHOT', :eid);
dbms_advisor.set_task_parameter(name, 'INSTANCE', :inst_num);
dbms_advisor.set_task_parameter(name, 'DB_ID', :dbid);
dbms_advisor.execute_task(name);
end;
end;
/
spool &report_name;
set long 1000000 pagesize 0 longchunksize 1000
column get_clob format a80
select dbms_advisor.get_task_report(:task_name, 'TEXT', 'TYPICAL')
from dual;
spool off;
prompt
prompt End of Report
prompt Report written to &report_name.
set termout on;
clear columns sql;
ttitle off;
btitle off;
repfooter off;
undefine report_name