Error ORA-01031: Insufficient Privileges While Refreshing Materialized View From A Procedure
(Doc ID 1663352.1)
Last updated on AUGUST 23, 2022
Applies to:
Oracle Database Cloud Service - Version N/A and laterOracle Database - Enterprise Edition - Version 11.2.0.4 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
Symptoms
After upgrading to 11.2.0.4 from 10G, you get the following error while refreshing Materialized View from a procedure. Refresh works fine from sql prompt:
SQL> CREATE OR REPLACE PROCEDURE <procedure_owner>."<procedure_name>" <==== Note: Procedure is created in <procedure_owner> schema.
2 IS
3 BEGIN
4 DECLARE
5 v_fora_grade VARCHAR2 (1);
6 v_nome_view VARCHAR2 (30);
7 v_error_message VARCHAR2(150);
8 BEGIN
9 DBMS_MVIEW.REFRESH ('<mview_owner>.<mview_name>', 'C'); <======Note, Materialized View is in mview_owner Schema.
10 EXCEPTION
11 WHEN OTHERS
12 THEN
13 v_error_message := SQLERRM ||' COMANDO : ' ||v_error_message;
14 --cetip.envia_mail (
15 --'gr.dados@cetip.com.br',
16 --'ERRO - Refresh <mview_name>',
17 --'Erro no refresh da view - mview_name'
18 --|| ' - '
19 --|| SQLERRM);
20 RAISE_APPLICATION_ERROR (-20051, v_error_message);
21 END;
22 END <procedure_name>;
23 /
Procedure created.
SQL> exec <procedure_owner>."<procedure_name>";
BEGIN <procedure_owner>."<procedure_name>"; END;
ERROR at line 1:
ORA-20051: ORA-01031:Insufficient Privileges
ORA-06512: em "<mview_owner>.<procedure_name>", line 20
ORA-06512: em line 1
SQL> exec DBMS_MVIEW.REFRESH ('<procedure_name>.<mview_name>', 'C');
PL/SQL procedure successfully completed.
If Mview and procedure are in the same schema, it works. If Mview and procedure are in different schemas, refresh works from command line but fails from procedure.
Changes
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Changes |
Cause |
Solution |