Here's another approach, that i think might be more robust because it just traps the exception that you want to avoid getting raised to the user.
Alternatively, you could code as ...Code:declare no_mv_log exception; pragma exception_init(no_mv_log,-12002); begin execute immediate 'drop materialized view log on my_table'; exception when no_mv_log then null; end;
... or even ...Code:declare mv_log_exists exception; pragma exception_init(mv_log_exists,-12000); begin execute immediate 'create materialized view log on my_table'; exception when mv_log_exists then null; end;
Code:declare mv_log_exists exception; pragma exception_init(mv_log_exists,-12000); begin execute immediate 'create materialized view log on my_table'; exception when mv_log_exists then execute immediate 'drop materialized view log on my_table'; execute immediate 'create materialized view log on my_table'; end;




Reply With Quote