而不是触发器不更新我的表

问题描述 投票:0回答:1

我必须检查一个表的新状态,根据这个状态,我需要更新与第一个表相关的另一个表。

原始表 = origin_table

视图 = table_view

视图是通过简单的选择创建的。

create or replace view table_view as
select * from table

我的触发器基本上是:

create or replace trigger verify_status
    instead of update on table_view
    referencing old as old new as new
    for each row

begin

    if :new.status in ('A', 'P') then
        update origin_table set status = 'CP' where cod = :new.cod;
    end if;
end;

但我的origin_table没有更新,有什么办法?

观察。view_table是一个与origin_table有关系的表的副本,而不是origin表的视图。

观察二:为了避免突变表的错误,我不得不这么做。

oracle plsql triggers database-trigger
1个回答
1
投票

我看不出你的代码有什么问题,它工作得很完美。你能不能检查一下dbfiddle链接,了解更多细节。

https:/dbfiddle.uk?rdbms=oracle_18&fiddle=8bad808cb6d120df37537044081e09b0。

© www.soinside.com 2019 - 2024. All rights reserved.