The number_of_failures parameter has a complicated relationship with the other parameters.
If refresh_after_errors is false (the default), the call will stop, raising the exception that caused the error. number_of_failures will not be set.
If you set refresh_after_errors to true, you then need to consider the value for atomic_refresh. When this is true (the default), the process will stop if it encounters
any failures. So there can only ever be one error, which is the one raised to you.
So if you set
refresh_after_errors => true,
atomic_refresh => false
the process will continue when encountering an exception. For reasons I don't know, this still leaves number_of_failures at zero when there's a problem. To get this to report the count of errors, it seems you also need to set:
nested => true,
out_of_place => true,
For example:
delete t_salary;
insert into t_salary values ( 1,11000 );
insert into t_salary values ( 1,11000 );
commit;
declare
n_failures number := 0;
begin
dbms_output.put_line ('Materialized view first refresh');
dbms_output.put_line ('============== 111 =============');
dbms_mview.refresh_dependent (
number_of_failures => n_failures,
list => 'MV_TABLE1',
atomic_refresh => false,
refresh_after_errors => true
);
dbms_output.put_line ('Number of failures: ' || n_failures);
exception
when others then
dbms_output.put_line ('Error: '
|| sqlerrm
|| ', Number of failures in EXCEPTION: '
|| n_failures);
end;
/
Materialized view first refresh
============== 111 =============
Number of failures: 0
delete t_salary;
insert into t_salary values ( 1,11000 );
insert into t_salary values ( 1,11000 );
commit;
declare
n_failures number := 0;
begin
dbms_output.put_line ('Materialized view second refresh');
dbms_output.put_line ('============== 222 =============');
dbms_mview.refresh_dependent (
number_of_failures => n_failures,
list => 'MV_TABLE1',
atomic_refresh => false,
nested => true,
out_of_place => true,
refresh_after_errors => true
);
dbms_output.put_line ('Number of failures: ' || n_failures);
exception
when others then
dbms_output.put_line ('Error: '
|| sqlerrm
|| ', Number of failures in EXCEPTION: '
|| n_failures);
end;
/
Materialized view second refresh
============== 222 =============
Number of failures: 1
TL:DR Your current parameter settings mean that the refresh stops as soon as it hits an error, making the number_of_failures value moot - there can only be one which is the exception raised to you. Changing these allows the refresh to continue after hitting an error.
There may be a bug where number_of_failures is incorrectly reported when continuing past errors, this is something you need to take up with support.
PS - to share Live SQL scripts, you need to save them as a (private) script. The URL of your worksheet is specific to you - others can't access this.