Chinaunix首页 | 论坛 | 博客
  • 博客访问: 280683
  • 博文数量: 72
  • 博客积分: 2387
  • 博客等级: 大尉
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-26 10:54
文章分类

全部博文(72)

文章存档

2012年(1)

2011年(1)

2010年(70)

分类: Oracle

2010-08-26 12:06:25

CREATE OR REPLACE TRIGGER dsmpsms_sort_tri
BEFORE INSERT ON tibco3.swi_in
FOR EACH ROW
DECLARE
isExist NUMBER;
tempMsg varchar2(128);
BEGIN
   --deal new's dsmp data
   isExist := 0;
   SELECT count(1) INTO isExist FROM cboss.DSM_SWI_MT_WAIT t where t.MSISDN=:new.phonenum and t.EXTEND_CODE=:new.termid_new
   and t.STATUS='U';
   if(isExist<>0) then
    tempMsg := :new.msg;
    update cboss.dsm_swi_mt_wait  set status = 'R', rsp_time = to_char(sysdate,'YYYYMMDDHH24MISS'), --rsp_msg=:new.msg
    rsp_msg=substr(tempMsg,length(:new.termid_new)+1,length(tempMsg)-length(:new.termid_new))
     where status = 'U' and MSISDN = :new.phonenum and EXTEND_CODE = :new.termid_new;
     --work 程序处理swi_in表里的status>0的数据,把status赋值为-999,为了work程序不会处理这部分数据
    :new.status := -999;
   end if;
  
   --deal old's dsmp data ,error
   --不能同时操作触发器的表
   --insert into tibco3.swi_in_bak select * from tibco3.swi_in where id<>:new.id and status=-999 ;
   --delete from tibco3.swi_in where id <> :new.id and status=-999;
EXCEPTION
 WHEN OTHERS THEN
 -- Consider logging the error and then re-raise
 RAISE;
END dsmpsms_sort_tri;
阅读(1099) | 评论(0) | 转发(0) |
0

上一篇:trigger

下一篇:rowtype/type

给主人留下些什么吧!~~