MySQL Forums
Forum List  »  Triggers

Simple Delete Trigger does not work
Posted by: Edoardo Piazza
Date: April 12, 2014 06:33AM

Hello!
I would like to keep track on the INSERT/UPDATE/DELETE action that are performed on some simple tables. There is an example that works fine:

http://www.sitepoint.com/how-to-create-mysql-triggers/

In the example the handling of the delete is done with a flagged field, but I would like that the record is removed from the blog table once deleted.
I modified and removed the delete condition on the INSERT and UPDATE cases and added a new trigger for the delete:

DELIMITER $$
CREATE
TRIGGER `blog_after_delete` AFTER UPDATE
ON `blog`
FOR EACH ROW BEGIN
SET @changetype = 'DELETE';
INSERT INTO audit (blog_id, changetype) VALUES (OLD.id, @changetype);
END$$
DELIMITER ;

In the INSERT I changed the value name "NEW.id" into "OLD.id" but the trigger will not work.
Even by changing into a BEFORE trigger it is still not working.

Any idea on how to solve this simple trigger?

Options: ReplyQuote


Subject
Views
Written By
Posted
Simple Delete Trigger does not work
2132
April 12, 2014 06:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.