oracle 触发器的问题!
时间:2011-09-06
来源:互联网
RT。。
我需要一个触发器。。两个表。。
当A表有增删改操作的时候,B表会根据A表中的一个字段来更新B表中对应类型的更新时间。。
这个要怎么写啊?
大题样子应该是这样
case ?????(这个条件怎么得到?)
where then
我需要一个触发器。。两个表。。
当A表有增删改操作的时候,B表会根据A表中的一个字段来更新B表中对应类型的更新时间。。
这个要怎么写啊?
大题样子应该是这样
case ?????(这个条件怎么得到?)
where then
作者: a392091921 发布时间: 2011-09-06
SQL code
参考下-也是刚刚学oracle create or replace trigger TRIGGER_PSANDCARSTATUS after insert on scm_psorder_isdn for each row declare INPSCODE VARCHAR2(100);--出库单号 spcode varchar2(200);--配送单号 outstorecode varchar2(200);--配送单上所有的出库单号 carplante varchar2(2000);--配送单上所有的车牌号 count_all_out integer;--配送单上的出库单数量 count_in_isdn integer;--已经'回执'的出库单数量 begin INPSCODE := :NEW.PSCODE;--把扫描编号赋值给变量 select pscode into spcode from scm_psorder where instr(outcode,INPSCODE,1)>0;--配送单号 select carid into carplante from scm_psorder where pscode=spcode;--配送单上的所有车辆 select outcode into outstorecode from scm_psorder where pscode=spcode;--配送单上的所有出库单号 update scm_outstore set outtype=2 where outcode=INPSCODE;--更新出库单状态为 "已回执" select count(*) into count_all_out from scm_outstore s where instr(outstorecode,s.outcode,1)>0;--配送单上的出库单数量 select count(*) into count_in_isdn from scm_outstore s1 where instr(outstorecode,s1.outcode,1)>0 and s1.outtype=2;--已经'回执'的出库单数量 if count_all_out=count_in_isdn then update scm_car c set c.car_free_status=0 where instr(carplante,c.number_plate,1)>0;--改变车辆的状态 '空闲' else update scm_psorder set status=2 where pscode=spcode and status<>2; end if; EXCEPTION WHEN NO_DATA_FOUND THEN update scm_psorder set status=2 where pscode=spcode and status<>2; end;
作者: szc108 发布时间: 2011-09-06
顶楼主
向1楼学习
向1楼学习
作者: delphisanding1 发布时间: 2011-09-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28