码迷,mamicode.com
首页 > 其他好文 > 详细

触发器

时间:2016-03-03 21:01:02      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:


drop trigger if exists tri_user;
delimiter $$
create trigger tri_user
BEFORE insert on t_user
FOR EACH ROW
BEGIN

declare count int;
declare bDate DATETIME;
declare uDate DATETIME;
declare days int;
select inTime,count(*) into bDate,count from t_agentmemberrel where memberName = NEW.username;
set uDate = NEW.createTime;
select datediff(bDate, uDate) into days ;
if count=1 THEN
IF days < 7 THEN
update t_agentmemberrel set activeStatus=‘2‘ where memberName = NEW.username;
END IF;
END IF;
END $$
delimiter ;

触发器

标签:

原文地址:http://www.cnblogs.com/webster1/p/5239724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!