SUMSEN

Oracle&Sql爱好者,用友NC管理员

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

create or replace trigger TNEWSAME
  before update on fts_newpayment  
  for each row
declare
  pk1 varchar2(80);
  pk2 varchar2(80);
  -- local variables here
begin
  select pk_newpayment into pk1 from fts_newpayment where pk_newpayment=:new.pk_newpayment
  and :new.balatype='1';
  select pk_newpayment into pk2 from fts_newpayment where pk_newpayment=:new.pk_newpayment
  and :new.balatype='2';
  update fts_newpayment_b set memo=memo||purpose where pk_newpayment=pk1;
  update fts_newpayment_b set memo=purpose where pk_newpayment=pk2;
 
end TNEWSAME;

据说是什么自治事务

简化版

 

create or replace trigger TNEWSAME
  before update on fts_newpayment  
  for each row
declare
  
  -- local variables here
begin
   
  update fts_newpayment_b set memo=purpose where pk_newpayment=:new.pk_newpayment;
 
 
end TNEWSAME;

更新2012-11-29

create or replace trigger TNEWSAME
  before update of auditdate on fts_newpayment  
  for each row
declare
  -- local variables here
begin   
  update fts_newpayment_b set memo=purpose where pk_newpayment=:new.pk_newpayment
  and memo is null;  
end TNEWSAME;

 

使用到了update of audituser on fts_newpayment,这样最大限量减少触发,但是这里第二步user不变,不知道为什么去掉and memo is null;触发器还是会变

15:11:46更新了|确认完结暂定|

create or replace trigger TNEWSAME
  before update of auditdate on fts_newpayment  
  for each row
declare
  -- local variables here
begin   
  if :new.iscashpay='Y' THEN 
     raise_application_error(-20001,'选择了现金业务,分公司反审核修改之后重新提交!');
     else
  update fts_newpayment_b set memo=purpose where pk_newpayment=:new.pk_newpayment
  and memo is null;  
  end if;
end TNEWSAME;

 

 

 2012-12-03 16:10:38 

想完善对外付款方式下“网上支付”忘记打钩的校验,不知道这个时候else还是否可以

create or replace trigger TNEWSAME
  before update of auditdate on fts_newpayment  
  for each row
declare
  -- local variables here
begin   
  if :new.iscashpay='Y' THEN 
     raise_application_error(-20001,'选择了现金业务,分公司反审核修改之后重新提交!');
     elsif :new.bustype='1' and :new.isnetsend='N' THEN
     raise_application_error(-20001,'对外付款必须选中网上支付,分公司反审核修改之后重新提交!');
     else
  update fts_newpayment_b set memo=purpose where pk_newpayment=:new.pk_newpayment
  and memo is null;  
  end if;
end TNEWSAME;

 

 

posted on 2012-11-28 15:28  sumsen  阅读(269)  评论(0编辑  收藏  举报