MySql触发器语句

删除

Drop trigger tri_cus_wallet_update;

 

创建

DELIMITER $

            触发器名        修改之后插入
CREATE TRIGGER tri_cus_wallet_update AFTER  UPDATE ON cus_wallet FOR EACH ROW
BEGIN
INSERT INTO cus_wallet_his(
orgid,
userid,
rechargemoney,
subsidymoney,
totalmoney,
integral,
rechargemoney_new,
subsidymoney_new,
totalmoney_new,
create_user,
create_time,
update_user,
update_time,
reserve1
)values(
OLD.orgid,
OLD.userid,
(NEW.rechargemoney-OLD.rechargemoney),  新值减旧值
(NEW.subsidymoney-OLD.subsidymoney),
OLD.totalmoney,
OLD.integral,
NEW.rechargemoney,
NEW.subsidymoney,
NEW.totalmoney,
OLD.create_user,
now(),
OLD.update_user,
now(),
NEW.reserve1
);
END $
DELIMITER ;

posted @ 2019-10-11 13:55  Mr_xYu  阅读(522)  评论(0编辑  收藏  举报