zoukankan      html  css  js  c++  java
  • 用友写insert on bd_custbank 触发器和自动更新单位名称2in1

    create or replace trigger S_INSERT_CUSTBANK
      before insert on bd_custbank
      for each row
    declare
      pk_bas char(20);
     vname varchar2(80);
      cursor basjob(id char) is
        select pk_custbank
          from ncv5.bd_custbank /*目标数据库表*/
         where pk_custbank = id
           and nvl(dr, 0) = 0;
    begin
      /*判断数据是否在目标数据库存在*/
      open basjob(:new.pk_custbank);
    
      loop
    
        fetch basjob
          into pk_bas;
    
        exit when basjob%notfound;
    
      end loop;
      close basjob;
      /******************************/
    
      if pk_bas is null then
    
        begin
       select custname
        into vname
        from bd_cubasdoc
       where pk_cubasdoc = :new.pk_cubasdoc;
    
      update bd_accbank
         set combineaccnum = :new.memo,
             unitname      = vname,
             city          = :new.accaddr,
             bankarea      = :new.accaddr
       where pk_accbank = :new.pk_accbank;
    
          insert into ncv5.bd_custbank /*目标数据库表*/
            (pk_custbank,
             pk_cubasdoc,
             accname,
             account,
             accaddr,
             defflag,
             memo,
             pk_accbank,
             pk_corp,
             pk_currtype,
             ts,
             dr)
          values
            (:new.pk_custbank,
             :new.pk_cubasdoc,
             :new.accname,
             :new.account,
             :new.accaddr,
             :new.defflag,
             :new.memo,
             :new.pk_accbank,
             :new.pk_corp,
             :new.pk_currtype,
             :new.ts,
             :new.dr);
        end;
    
      end if;
    
    end addbd_custbank;
  • 相关阅读:
    [hdu2196]Computer树的直径
    [poj2342]Anniversary party树形dp入门
    链式前向星模板
    LintCode-50.数组剔除元素后的乘积
    Markdown的基本语法
    LintCode-8.旋转字符串
    LintCode-1.A + B 问题
    LintCode-61.搜索区间
    LintCode-88.最近公共祖先
    LintCode-54.转换字符串到整数
  • 原文地址:https://www.cnblogs.com/sumsen/p/2555329.html
Copyright © 2011-2022 走看看