触发器


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 ;

posted @ 2016-03-03 18:56  吴某1  阅读(165)  评论(0编辑  收藏  举报