Error ORA-01031: Insufficient Privileges While Refreshing Materialized View From A Procedure (Doc ID 1663352.1)

Last updated on APRIL 18, 2014

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.4 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 TEST."P_REFRESH_MV_POS_CUST_MALOTE" <==== Note: Procedure is created in TEST 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 ('TEST2.VM_POSICOES_CUSTODIA_MALOTE', 'C'); <======Note, Materialized View is in TEST2 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 da View Materializada Posicoes_Custodia_Malote',
17   --'Erro no refresh da view - VM_POSICOES_CUSTODIA_MALOTE'
18   --|| ' - '
19   --|| SQLERRM);
20   RAISE_APPLICATION_ERROR (-20051, v_error_message);
21   END;
22   END P_REFRESH_MV_POS_CUST_MALOTE;
23  /

Procedure created.


SQL> exec test."P_REFRESH_MV_POS_CUST_MALOTE";
BEGIN test."P_REFRESH_MV_POS_CUST_MALOTE"; END;


ERROR at line 1:
ORA-20051: ORA-01031:Insufficient Privileges
ORA-06512: em "TEST2.P_REFRESH_MV_POS_CUST_MALOTE", line 20
ORA-06512: em line 1

SQL> exec DBMS_MVIEW.REFRESH ('TEST.VM_POSICOES_CUSTODIA_MALOTE', '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.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms