主页 M

高质量触发器欣赏

2014-06-04 网页编程网 网页编程网

在做那个入库时,把订单的关闭程序时。

create trigger orderClose
after insert on receive
for each row
begin
set @sum=(select sum(qty) from receive where number=new.number group by number);
set @sumOrder=(select qty from order_info where num=new.number group by num);
if @sum=@sumOrder then
    update order_info set valid="1" where num=new.number;
end if;
end//
drop trigger orderClose//
阅读原文
阅读 3907
123 显示电脑版