触发器可以在我们对表数据进行修改时,级联关联其它数据发生变化。

触发有前后之分,前的话我们可以在这笔数据的事件执行前来做一些事情。

create or replace trigger update_sendFlg
  before insert
  on T_MOT_LINE_SECTION_HISTORY 
  for each row
declare
  -- local variables here
begin
  if :new.send_flag = 'insert' then
     :new.send_flag := 'update';
  end if;
end update_sendFlg;

而后的话,因默认触发器事件和操作事件在一个事务中进行,因此在我们insert一笔数据时,在事件后中查不到这笔数据。因此有可能需要分事务进行。

在declare中添加:

pragma autonomous_transaction; 

 

posted on 2018-08-13 13:36  zhaoqiang1980  阅读(84)  评论(0)    收藏  举报