Report based on MV: Deliberately make the report fail if MV is out of date?
-
13-03-2021 - |
Question
I have a query that is used in a BIRT report (in IBM's Maximo Asset Management platform).
I'm considering storing the query in a materialized view in order to improve performance and reduce the load on the system.
Question:
Is a way to deliberately make the report fail if the MV is out-of-date?
- In other words, we'd rather have no data in the report, than wrong data.
Edit:
I removed the excessive details from the question.
Solution
Why bother at all with a new column, when you can just check LAST_REFRESH_DATE
in ALL_MVIEWS
before executing the actual query.
OTHER TIPS
To build on @BalazsPapp's answer:
I can check the LAST_REFRESH_DATE in ALL_MVIEWS or USER_MVIEWS:
select
*
from
wo_mv
where
exists (select 1
from all_mviews
where mview_name = 'WO_MV'
and trunc(last_refresh_date) = trunc(sysdate)
)
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange