the following SP is not working tho it compiles fine.
Looks like the "for x in select " is not working....any suggestion ??
CREATE OR REPLACE PROCEDURE analyze_partition(
part_name IN VARCHAR2)
IS
TYPE x_type IS REF CURSOR;
x x_type;
x_part_name varchar2(200) := upper(part_name);
BEGIN
dbms_output.put_line('X_PART_NAME: '|| x_part_name);
for x in (select table_name,partition_name from dba_tab_partitions
where table_owner = 'MDM3'
and partition_name like 'x_part_name%'
and last_analyzed is null)
loop
begin
exec sys.dbms_stats.gather_table_stats(ownname => 'MDM3', -
tabname => x.table_name, -
partname => x.partition_name, -
estimate_percent => 30, -
block_sample => false,-
method_opt => 'FOR ALL COLUMNS SIZE 1', -
degree => 8, -
granularity => 'default', -
cascade => true , -
stattab => null, -
statid => null, -
statown => null);
exception
when others then
dbms_output.put_line('### ERROR: ' || sqlerrm);
end;
end loop;
end;
1 select table_name,partition_name from dba_tab_partitions
2 where table_owner = 'MDM3'
3 and partition_name like 'MTH2005JAN%'
4* and last_analyzed is null
SQL> /
and partition_name like 'x_part_name%'
should be
and partition_name like x_part_name||'%'
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
I'm taking a more leisurely approach to life. And if you can only beat me to it by a matter of seconds, you'd better look to your laurels, young whipper-snapper.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Wouldn't it make sense to simply use dbms_stats?
I think GATHER_SCHEMA_STATS with the parameter OPTIONS set to GATHER AUTO, GATHER STALE or GATHER EMPTY would be a nicer solution.
Bookmarks