Materialized View "MV_AMP":
CREATE MATERIALIZED VIEW MV_AMP
NOLOGGING
BUILD IMMEDIATE
REFRESH FORCE
ON DEMAND
AS
Select a, b, c from amp;
Materialized View "MV_BOT" that dependens on "MV_AMP":
CREATE MATERIALIZED VIEW MV_BOT
NOLOGGING
BUILD IMMEDIATE
REFRESH FORCE
ON DEMAND
AS
SELECT bot.x, bot.y, mv_amp
FROM bot, mv_amp
WHERE bot.a = mv_amp.a;
And create a unique index in mv_bot:
CREATE UNIQUE INDEX mv_bot_idx001 ON mv_bot(x, a);
After views and index create successful, suppose I add a duplicate value that cause an error like (dup_val_on_index) when refresh the mv_bot due the unique index.
So I do a refresh in MV_AMP (the main view) using nested=TRUE, and Oracle didn't raise an error:
BEGIN
dbms_mview.refresh_dependent(number_of_failures => n_failures,
list => 'MV_AMP',
atomic_refresh => TRUE,
nested => TRUE);
EXCEPTION
WHEN
OTHERS THEN
-- it never reach this code
dbms_output.put_line('Errors: '||SQLERRM);
END;
n_failures returns: 0 and it never reaches the dbms_output inside the exception.
I need to catch the error when oracle tries to updates the nested MVs and log in a table.
Using Oracle 11g.