I'm using 4 materialized views on my oracle 12c - all of them are updated manually by a stored procedure call.
All views include a lookup to context variable in where clause including a time span (from and to).
Context was created by
CREATE OR REPLACE CONTEXT myContext using prepare_export;
No view has any relation to other views except using the same user context but different variable names.
Execution Chain is (only one view should be refreshed):
execute prepare_export('MyViewName','20180131','20180231');
entry in data_export table is generated for data_export logging
INSERT INTO DATA_EXPORT (SOURCE_,EXPORT_TIME_,EXPORT_FROM_,EXPORT_TO_,user_name,user_ip) VALUES (viewName,systimestamp,date_From,date_To,(select user from dual),(select sys_context('userenv','ip_address') from dual));`
context variables are set (from:20180131 and to:20180231)
dbms_session.set_context('myContext',viewName || '_from',date_from); dbms_session.set_context('myContext',viewName || '_to',date_to);
view MyViewName gets refreshed (atomic refresh false)
dbms_mview.refresh(viewName,'c',atomic_refresh=>FALSE);
data_export entry gets updated with count(*) of last refresh
execute immediate 'UPDATE data_export set resultset_size_=' ||viewRowCount ||' where id_ = (select max(id_) from data_export where source_=''' || viewName || ''' group by source_)';
After the procedure has completed all views become invalid and need to be recompiled manually...
Any help out there?
Thx, Joe