zoukankan      html  css  js  c++  java
  • 触发器实例(二)

    create or replace trigger TR_T_DWXX
    after delete or update or insert ON T_DWXX
     for each row
    --单位 改变后 修改单位关系表
    declare
      curr_dwdh number:=0 ;
      PRAGMA AUTONOMOUS_TRANSACTION;--开启自治事物
      i number:=0;
    BEGIN
    
      if inserting then
         select t.n_sjdw into curr_dwdh from t_dwxx t where t.n_dwdh=:new.N_SJDW;
         loop -- 循环语句,找出当前节点上面还有几层节点,即分析当前节点是第几级
             exit when curr_dwdh =99999999;--根节点就退出
    
             INSERT INTO T_DWGX (N_DWDH,N_XJDW,N_GXJS)
              values (curr_dwdh,:new.N_DWDH,i);
              i:=i+1;
             select t.n_sjdw into curr_dwdh from t_dwxx t where   t.n_dwdh=curr_dwdh;
         end loop;
         INSERT INTO T_DWGX (N_DWDH,N_XJDW,N_GXJS)
          values (:new.N_SJDW,:new.N_DWDH,i);
      elsif updating then
        delete from T_DWGX where N_XJDW=:old.n_dwdh;
        select t.n_sjdw into curr_dwdh from t_dwxx t where t.n_dwdh=:new.N_SJDW;
        loop --循环语句,找出当前节点上面还有几层节点,即分析当前节点是第几级
             exit when curr_dwdh =99999999;--根节点就退出
              INSERT INTO T_DWGX (N_DWDH,N_XJDW,N_GXJS)
              values (curr_dwdh,:new.N_DWDH,i);
               i:=i+1;
             select t.n_sjdw into curr_dwdh from t_dwxx t where   t.n_dwdh=curr_dwdh;
        end loop;
        INSERT INTO T_DWGX (N_DWDH,N_XJDW,N_GXJS)
          values (:new.N_SJDW,:new.N_DWDH,i);
      elsif deleting then
         delete from T_DWGX where N_XJDW=:old.n_dwdh;
      end if;
    COMMIT;
    END;
  • 相关阅读:
    CCNode作为容器实现显示区域剪裁
    使用CCNode作为容器容易踩的坑
    走了很多弯路的CCScrollView
    常用es6特性归纳-(一般用这些就够了)
    WebP图片优化
    es6 Promise 异步函数调用
    网站性能优化
    dom元素分屏加载
    js顺序加载与并行加载
    移动端真机调试
  • 原文地址:https://www.cnblogs.com/mingyue1818/p/3327167.html
Copyright © 2011-2022 走看看