We currently are working on a bug with Oracle Support with dbms_stats in 12.1.0.2.
That may be the subject of a latter post, but in a nutshell, here’s the issue
SQL> exec dbms_stats.gather_table_stats('MY_SCHEMA', 'MY_SCHEMA');
BEGIN dbms_stats.gather_table_stats('MY_SCHEMA', 'MY_SCHEMA'); END;
*
ERROR at line 1:
ORA-21700: object does not exist or is marked for delete
Now obviously that’s not meant to be happening, and it pertains to incremental stats on a database that’s been upgraded from 12.1.0.1 to 12.1.0.2. More on that another time.
But as we work on the bug, a seemingly obvious measure would be to catch that exception and move on…So lets try that, in fact, lets be brutal and ignore all errors, mainly for the purpose of the example, but also to raise the hackles of good friend Tom 🙂
SQL> begin
2 dbms_stats.gather_table_stats('MY_SCHEMA', 'MY_SCHEMA');
3 exception
4 when others then
5 null;
6 end;
7 /
begin
*
ERROR at line 1:
ORA-21700: object does not exist or is marked for delete
Interesting…
By the way, if you’re encountering this issue, delete your INCREMENTAL stats preference as a temporary workaround.
Interesting – can you catch that particular error using pragma exception_init?
dbms_stats is special. Possibly related : http://laurentschneider.com/wordpress/2014/05/disable-commit-in-procedure.html