-- Created by util.you.com@gmail.com
-- 声明变量,用于存入 CXY_TS_ORDER_TICKET 表的 get_status 字段值,id 字段值
-- 分别给 s1 和 s2 赋值
delimiter $$
CREATE TRIGGER `order_ticket_status_trigger` AFTER UPDATE
ON `CXY_TS_ORDER_TICKET` FOR EACH ROW
BEGIN
DECLARE s1 INT(11);
DECLARE s2 INT(11);
set s2 = new.id;
set s1 = new.get_status;
IF((old.get_status != new.get_status) OR (old.get_status IS NULL && new.get_status IS NOT NULL)) THEN
INSERT INTO `CXY_TS_ORDER_TICKET_STATUS`(`order_ticket_id`, `STATUS`, `insert_date_time`) VALUES(s2, s1, DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s'));
END IF;
END$$