Home » SQL & PL/SQL » SQL & PL/SQL » How to create Dependency in MV (Oracle 11G)
How to create Dependency in MV [message #649708] Mon, 04 April 2016 07:43 Go to next message
irish
Messages: 5
Registered: April 2016
Junior Member
Hi Good Morning.!!!

I am Irisha and working as oracle developer with 1.7 yr exp. New to this forum. Need your help on below.

I have 2 materialized view and have Refresh scheduled like below

1) MV_COT_REFRESH 9 PM EST
2) MV_CUST_REFRESH 10 PM EST

Now, i have requirement to create dependency between these two MV's

IF first one completes then only need to start the Second one. Is there any way we can do in oracle.

Please need your help on this.

Thank you
Re: How to create Dependency in MV [message #649710 is a reply to message #649708] Mon, 04 April 2016 07:52 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Create a refresh group.

https://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_refrsh.htm#ARPLS043

Re: How to create Dependency in MV [message #649713 is a reply to message #649710] Mon, 04 April 2016 09:33 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
Not sure how refresh group will help here - OP wants to refresh MVs at different time.
OP needs to create DBMS_SCHEDULER chain.

SY.
Re: How to create Dependency in MV [message #649762 is a reply to message #649710] Tue, 05 April 2016 09:16 Go to previous messageGo to next message
irish
Messages: 5
Registered: April 2016
Junior Member
Thanks for your reply.

Will DBMS_REFRESH help to create a dependency between two MV's

After completion of first MV need to start another one.

[Updated on: Tue, 05 April 2016 09:29]

Report message to a moderator

Re: How to create Dependency in MV [message #649763 is a reply to message #649762] Tue, 05 April 2016 10:10 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Did you read the documentation?

Re: How to create Dependency in MV [message #649767 is a reply to message #649762] Tue, 05 April 2016 12:35 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Is your requirement to make the refresh of both MVs transactionally consistent? Or is it something else?
Re: How to create Dependency in MV [message #649811 is a reply to message #649767] Wed, 06 April 2016 22:20 Go to previous messageGo to next message
irish
Messages: 5
Registered: April 2016
Junior Member
After the Completion of First one. Need to start the Second one.
Re: How to create Dependency in MV [message #649814 is a reply to message #649811] Thu, 07 April 2016 00:35 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Why? What is the reason??
Re: How to create Dependency in MV [message #649825 is a reply to message #649814] Thu, 07 April 2016 09:38 Go to previous messageGo to next message
irish
Messages: 5
Registered: April 2016
Junior Member
Hi

Second view is using data from first view
Re: How to create Dependency in MV [message #649827 is a reply to message #649825] Thu, 07 April 2016 09:54 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
I would use the Scheduler. Do it with a job chain.
Re: How to create Dependency in MV [message #649832 is a reply to message #649827] Fri, 08 April 2016 06:19 Go to previous messageGo to next message
gajini
Messages: 262
Registered: January 2006
Senior Member
Thank you
Re: How to create Dependency in MV [message #649969 is a reply to message #649832] Mon, 11 April 2016 10:42 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Only use the job chain if they have to run at 9am and then 10am. If the second one is only run at 10am to make sure that the first update has been completed then you can set it up 2 ways. Use a refresh group.

make the group by using the following call. For purposes of this task, I will call the refresh group MY_REFRESH. You can call it anything.

EXEC dbms_refresh.make('MY_REFRESH');

Now add the two Mviews into the group

EXEC DBMS_REFRESH.ADD(NAME => 'MY_REFRESH',LIST => 'MV_COT_REFRESH,MV_CUST_REFRESH',LAX => TRUE, nested => TRUE);

Now setup a dbms_job telling it to run everyday at 9am

DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
  ( job       => X 
   ,what      => 'dbms_refresh.refresh(''MY_REFRESH'');'
   ,next_date => to_date('12/04/2016 09:00:00','dd/mm/yyyy hh24:mi:ss')
   ,interval  => '(TRUNC(SYSDATE)+1)+ 9/24'
   ,no_parse  => FALSE
  );
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
/


It will now run your refresh in the correct order (uses dependencies) for both jobs and if the first one blows, it will not run the second one.

Also are you doing a complete refresh or a fast refresh. It makes a big difference in the refresh. To use the fast refresh, you would have to set up a MVIEW log on the original base table that the MV_COT_REFRESH uses. You might also be able to pull from the base tables that MV_COT_REFRESH uses for the MV_CUST_REFRESH if you have set up the MVIEW logs.

[Updated on: Mon, 11 April 2016 12:37]

Report message to a moderator

Re: How to create Dependency in MV [message #650002 is a reply to message #649969] Tue, 12 April 2016 06:13 Go to previous message
gajini
Messages: 262
Registered: January 2006
Senior Member
Thank you very much. I will try and let you know
Previous Topic: difference between "child rows" and "siblings rows "
Next Topic: Summation on Character Variables
Goto Forum:
  


Current Time: Thu Apr 25 07:53:28 CDT 2024