zoukankan      html  css  js  c++  java
  • 建行个人卡不能委付trigger|itpub版主已经版主解决||触发器不能读它问题|

    create or replace trigger NOPAYFREE2
      before insert  on arap_djfb 
      for each row
    declare
      -- local variables here
      pk_bas char(20);
    
    begin
      select distinct bd_cubasdoc.custname
        into pk_bas
        from bd_cubasdoc, arap_djfb, bd_cumandoc
       where bd_cumandoc.pk_cubasdoc = bd_cubasdoc.pk_cubasdoc    
         and  bd_cumandoc.pk_cumandoc=:new.ksbm_cl  
         and :new.fkyhmc is null
         and bd_cubasdoc.freecustflag = 'Y';
         
      if pk_bas is not null then
        raise_application_error(-20001, pk_bas || '是建行个人卡,不能委托中心付款!');
      
      end if;
       exception
      when no_data_found then  
        return;
    
    end NOPAYFREE2;

    目前正常的保存之后update有问题,待优化

    针对加上update就提示找不到的问题,一路的意见:

    不是null,我就不让它触发
    一路-江苏南京  17:26:38
    最好使用函数来转换下再判断
    Sumsen♂  17:26:55
    nvl?
    一路-江苏南京  17:27:16

    Sumsen♂  17:27:33
    里面写:new吗
    一路-江苏南京  17:27:55

    有时候字段虽然看起来没内容,但是值不是null

    下面这样写也是报错,不能读它
    create or replace trigger NOPAYFREE2
      before insert or update  on arap_djfb 
      for each row
    declare
      -- local variables here
      pk_bas char(20);
    
    begin
      select distinct bd_cubasdoc.custname
        into pk_bas
        from bd_cubasdoc,  bd_cumandoc,arap_djfb,arap_djzb
       where bd_cumandoc.pk_cubasdoc = bd_cubasdoc.pk_cubasdoc    
         and  bd_cumandoc.pk_cumandoc=:new.ksbm_cl 
         and arap_djzb.vouchid=:new.vouchid 
         and  arap_djzb.djlxbm='23A1'
         and bd_cubasdoc.freecustflag = 'Y';
      if pk_bas is not null then
        raise_application_error(-20001, pk_bas || '是建行个人卡,不能委托中心付款!');
      
      end if;
       exception
      when no_data_found then  
        return;
    
    end NOPAYFREE2;

    2012.5.13下午更新:刚出差回来,感谢itpub版主ZALBB,少一个from表就ok了

    create or replace trigger NOPAYFREE
      before insert or update on arap_djfb
      for each row
    declare
      -- local variables here
      pk_bas char(20);
     
    begin
      select distinct bd_cubasdoc.custname
        into pk_bas
        from bd_cubasdoc, bd_cumandoc
       where bd_cumandoc.pk_cubasdoc = bd_cubasdoc.pk_cubasdoc   
         and  bd_cumandoc.pk_cumandoc=:new.ksbm_cl  
         and :new.fkyhmc is null
         and bd_cubasdoc.freecustflag = 'Y';
         
      if pk_bas is not null then
        raise_application_error(-20001, pk_bas||'-->账户是建行个人卡,不能使用委托中心付款!请当地行支付。');
     
      end if;
       exception
      when no_data_found then  
        return;
     
    end NOPAYFREE;

    学习总结:触发器写的时候,针对那个表,下面使用select into用法时候from表就不需要引用针对的表

  • 相关阅读:
    抽象类和接口
    truncate,delete和drop的区别
    PLSQL乱码问题
    Linux
    myEclipse闪退
    Java 中 Synchronized 的使用
    工厂模式
    Java中的File,IO流
    jQuery的学习
    C++中的标准模板库STL
  • 原文地址:https://www.cnblogs.com/sumsen/p/2524688.html
Copyright © 2011-2022 走看看