Oracle SQL 刷新语句后的物化视图...有这样的东西吗?

Oracle SQL Materialized view after refresh statement... is there such a thing?

我想在实体化视图刷新后 运行 一些代码。是否有某种 "after" 语法可以让我在物化视图刷新后 运行 编码?

我不断收到 google 次点击谈论在语句后刷新实体化视图,但这与我想做的完全相反。我想在实体化视图刷新后 运行 一个语句(基本上称为 API)。

谢谢,

约翰

是什么阻止您在 mview 上创建插入后触发器?

POC

Connected to Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 

SQL> create materialized view mv_test
SQL>     build deferred
SQL>     refresh complete with rowid on demand
SQL> as
SQL> select *
SQL> from c_country
SQL> ;

Materialized view created

SQL> create or replace trigger trg_mv_test_after_insert
SQL>     after insert on mv_test
SQL> begin
SQL>     dbms_output.put_line('the mview has been refreshed at '||systimestamp);
SQL> end;
SQL> /

Trigger created

SQL> begin
SQL>     dbms_mview.refresh('MV_TEST','C');
SQL>     dbms_session.sleep(1);
SQL>     dbms_mview.refresh('MV_TEST','C');
SQL>     dbms_session.sleep(2);
SQL>     dbms_mview.refresh('MV_TEST','C');
SQL>     dbms_session.sleep(1);
SQL>     dbms_mview.refresh('MV_TEST','C');
SQL> end;
SQL> /

the mview has been refreshed at 15.11.19 09:30:51,686000000 +01:00
the mview has been refreshed at 15.11.19 09:30:52,729000000 +01:00
the mview has been refreshed at 15.11.19 09:30:54,768000000 +01:00
the mview has been refreshed at 15.11.19 09:30:55,805000000 +01:00

PL/SQL procedure successfully completed

SQL> 

很有魅力!

脚注

当然,可快速刷新的 mview 可能需要额外的触发点 -- deleteupdate

尝试使用您的用例并自己找到最终的解决方案。