Reputation: 193
I am trying to make a simple trigger that logs update events. However I get Error near " BEGIN ...". if I use single quotes, i.e. 'update_log' and 'customer', then the error is near ' 'update_log....'
use tal;
delimiter //
CREATE TRIGGER onUpdate
BEFORE UPDATE ON customer
BEGIN
INSERT INTO update_log VALUES(user(), 'An Udpdate operation against the customer table.', now());
END//
delimiter ;
Why does this not work?
Upvotes: 0
Views: 22
Reputation: 26784
Unlike Oracle mysql needs FOR EACH ROW
delimiter //
CREATE TRIGGER onUpdate
BEFORE UPDATE ON customer
FOR EACH ROW
BEGIN
INSERT INTO update_log VALUES(user(), 'An Udpdate operation against the customer table.', now());
END//
delimiter ;
Upvotes: 1