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;
  • 相关阅读:
    c++ 队列
    17:特殊类成员:函数指针5
    c++ deque 双端队列
    18:字符串-char型字符串
    c++ 16 this 和 继承 及继承机制中的构造函数 与 析构函数
    c++ string char* const char*
    c++ 小片段
    google protobuf 使用示例
    hibernate-cache
    hibernate-criteria查询(二)
  • 原文地址:https://www.cnblogs.com/sumsen/p/2555329.html
Copyright © 2011-2022 走看看