Materialized view calling pl/sql table function

Guys

I have an issue.

I have created a materialized view which calls a plsql table function to populate itself.

Here is the code:-

create materialized view data_gmsone.wasd_spells
parallel
nologging
refresh complete next trunc(sysdate) + 1
as
SELECT *
FROM TABLE(control.WASD_CALC_SPELL_9i(CURSOR(      
            select  /*+ use_hash(a) */ nino$1 ,
                  benefit$1,
                  claim_start_date$1,
                  wasd_claim_end_date$1
            from data_gmsone.data_gmsone_cust_ben_dets a
            where s$delflag = 'I'
            and (MAX_CLAIM_DATE$1 is null or MAX_CLAIM_DATE$1 > '28-JUN-1999')
            and BENEFIT$1 in ('JUV', 'IS', 'IB', 'SDA', 'ICA', 'WB', 'BB' , 'PC')
            and CLAIM_START_DATE$1 is not null
            and CUSTOMER_TYPE$1 = 'C'
            order by nino$1, claim_start_date$1)
                  )
      );

It creates fine, but the dbms_job refresh that gets created fails with

control@assist_o> exec dbms_refresh.refresh('"DATA_GMSONE"."WASD_SPELLS"');
BEGIN dbms_refresh.refresh('"DATA_GMSONE"."WASD_SPELLS"'); END;

*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
ORA-06512: at "SYS.DBMS_IREFRESH", line 683
ORA-06512: at "SYS.DBMS_REFRESH", line 195
ORA-06512: at line 1

I dont understand this. The source tables exist. I have granted execute on the table function to the owner of the materialized view. The materialized view works when I create it, but doesnt work on a refresh.!!! I have tried the refresh under several users including the owner and a dba, and get the same error message for all of them.

Any ideas?
LVL 6
morphmanAsked:
Who is Participating?
 
morphmanConnect With a Mentor Author Commented:
I am executing the refresh via user DATA_GMSONE who owns the mview. I have other mviews in this user that do refresh (on the same source tables)

I think I have found the problem.

The mview calls user defined types and packages created in user CONTROL. however, how do I grant enough permissions for the refresh job to be able to run and DATA_GMSONE to be able to access the control.package?

For info, the mview created fine in DATA_GMSONE, its only the refresh job failing!!
0
 
catchmeifuwantCommented:
try this(without the quotes) :

exec dbms_refresh.refresh('DATA_GMSONE.WASD_SPELLS');
0
 
morphmanAuthor Commented:
nope, same error. the refresh job was not added by me, it was added automatically y the creation of the mview.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
catchmeifuwantCommented:
Do you(the user who is executing the procedure) have access rights on the Materialized view? Check that...
0
 
anand_2000vCommented:
The problem is with the dbmsmv.sql and prvtmv.plb.....copy them from another system which has a slightly different version of oracle.
0
 
morphmanAuthor Commented:
anand 2000v, please can you explain why the problem is to do with those scripts?

We have just performed an upgrade fmro 8i to 9i on our system. All of our systems are now 9i, so they will all have the same versions of those scripts.
0
 
anand_2000vCommented:
sorry for not being online...
I have observed the same problems in Oracle 8i. I just copied those scripts and executed them in sys login and then it started working. your problem might be that you could have done a migration and not an exp/imp method. if so....
$sqlplus
username:sys as sysdba
Password:<type ur password>
SQL> @$ORACLE_HOME/rdbms/admin/dbmsmv.sql
SQL> @$ORACLE_HOME/rdbms/admin/prvtmv.plb
and then check whether it works
0
 
anand_2000vCommented:
sorry did not go through it properly...
ignore my previous comments

let's suppose that you are executing the refresh command through a user "USER1".

log on as DATA_GMSONE and give the command
grant refresh<or all> on WASD_SPELLS to user1;
grant refresh < or all> on data_gmsone_cust_ben_dets to user1;


if they have been given via a role then you might have this problem
0
 
anand_2000vCommented:
why me? you should have asked for a refund as no one gave you a solution?
0
 
morphmanAuthor Commented:
Its not a problem, as I get unlimited points anyway, but as I dont want to abuse that, for future reference, how to you request a refund?

I have left messages on my questions before, and they just sat open, and I dont like open questions.
0
All Courses

From novice to tech pro — start learning today.