mình có trigger như sau :
Code:
DELIMITER //
DROP TRIGGER IF EXISTS update_type_tour
CREATE TRIGGER update_type_tour
AFTER UPDATE ON ct_tour_type
FOR EACH ROW
BEGIN
DECLARE temp varchar(4), temp_new varchar(100);
IF OLD.description != NEW.description THEN
SET temp = OLD.description, temp_new = NEW.description;
END IF;
IF OLD.tour_type_code != NEW.tour_type_code THEN
SET temp = OLD.tour_type_code, temp_new = NEW.tour_type_code;
END IF;
IF OLD.description != NEW.description AND OLD.tour_type_code != NEW.tour_type_code THEN
SET temp = CONCAT(OLD.tour_type_code, ' và ', OLD.description), temp_new = CONCAT(NEW.tour_type_code, ' và ', NEW.description);
END IF;
INSERT INTO ct_log (done_by, done_work, done_date, action_flag) VALUES(NEW.last_aceessed_by, CONCAT('Cập nhật ', temp, ' thành ', temp_new), NOW(), 'update');
END //
DELIMITER ;
mình chạy dc cái lệnh này thì successful nhưng sao khi update trên bảng ct_tour_type mà nó không insert được vào bảng ct_log nhỉ? mới tập tành viết trgger mong mn giúp
vừa thử lại mà nó báo #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TRIGGER update_type_tour AFTER UPDATE ON ct_tour_type FOR EACH ROW BE' at line 2
chả hiểu nổi :-?
Mình xin cảm ơn trước !
Bookmarks