触发器

Posted Dota_小川

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了触发器相关的知识,希望对你有一定的参考价值。

 

create or replace TRIGGER CAR_TEAM_LOAD_QUANTITY_TRG AFTER
  INSERT OR
  UPDATE ON ATT_TRADE
  DECLARE FK_CAR_TEAM_TASK NUMBER(15,0);--车队任务id
  TOTAL_LOAD_NUM NUMBER(15,3);                                                --已疏港量
  logid integer;
  contentstr varchar(4000);
  CURSOR numlist is
    (SELECT team.id id, SUM(trade.net) net
    FROM CAR_TEAM_DISPACHER_INFO team
    LEFT JOIN ATT_VEHICLEDISPATCH dis
    ON team.id=dis.FK_CAR_TEAM_DISPACHER_INFO_ID
    LEFT JOIN ATT_TRADE trade
    ON trade.FLEETTASKID  =dis.id
    WHERE trade.DATASTATUS=1 and trade.FLEETTASKID is not null
    GROUP BY team.ID);
  BEGIN
   FOR num_row IN numlist LOOP
   begin
    update CAR_TEAM_DISPACHER_INFO set LOAD_QUANTITY=num_row.net/1000 where id=num_row.id;
     exception
        when others then
          SELECT WEBLOG_SEQ.NEXTVAL INTO logid FROM SYS.DUAL;
              contentstr := update CAR_TEAM_DISPACHER_INFO set LOAD_QUANTITY=||num_row.net||where id=||num_row.id;
          insert into weblog (id,context) values (logid,contentstr);
   end;
  end loop;
END;

 

以上是关于触发器的主要内容,如果未能解决你的问题,请参考以下文章

导航到另一个片段时触发 API 调用

我如何使用 codeanywhere 片段

前端防扒代码片段

前端防扒代码片段

前端防扒代码片段

前端防扒代码片段