DBMS_Snapshot.refresh not working on 11g , materialized view error
Question
I executed DBMS_Snapshot.refresh
on Oracle 10g
it worked fine, but when i execute the same on Oracle 11g
it gives the following error
DBMS_SNAPSHOT.refresh('Table1','F');
BEGIN DBMS_SNAPSHOT.refresh('Table1','F'); END;
.
*
ERROR at line 1:
ORA-23401: materialized view "localuser"."Table1" does not
exist
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2558
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2771
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2740
ORA-06512: at line 1
Any help much appreciated
Regards.
Nandish
Solution
OK, there may be many reasons for this.
You didn't recreate the MV yet in 11g. You can't refresh an MV to create it.
You didn't recreate a synonym (public or private) to the schema where the MV is located.
You didn't recreate grants to the MV in another schema, so create them.
You might try DBMS_MVIEW instead of DBMS_SNAPSHOT.
exec dbms_mview.refresh('Table1');
OTHER TIPS
The error message suggests that it is looking for "Table1"
in a case sensitive manner. Try passing in 'TABLE1'
instead.
My case was little different. The DBMS_MVIEW.REFRESH('ABC.XYZ') call happens from a oracle stored procedure (SCHEMA1.PROC1). I was calling the SP as a different user (UserA). I have given all permissions to the user, but to no awail. Apparently, oracle dont seem to care about the permission the user has, it looks for the permissions for the package owner.. this is very odd and contrary to what I ready everywhere.. but it did work
didnt work:
GRANT ALTER ANY MATERIALIZED VIEW TO UserA;
GRANT SELECT ON ABC.MLOG$_XYZ TO UserA;
Worked:
GRANT ALTER ANY MATERIALIZED VIEW TO SCHEMA1;
GRANT SELECT ON ABC.MLOG$_XYZ TO UserA, SCHEMA1;