MySQL Forums
Forum List  »  Triggers

Trigger generating Error On INSERT
Posted by: IGGt .
Date: May 20, 2011 06:48AM

I have a trigger I have devised that is designed so that when a row is INSERTED into a table, if it matches, then the trigger adds a second row.

But it doesn't work, I keep getting "Can't update table 'tablename' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

The trigger is:

delimiter //
CREATE TRIGGER triggertest
AFTER INSERT
ON tablename
FOR EACH ROW
BEGIN
IF NEW.state = 4
AND NEW.Task = 300
THEN
INSERT IGNORE INTO tablename
(State, task, Data)
VALUES (5,300,'stuff');
END IF;
END
;
//

and the query is:
INSERT INTO tablename
VALUES (4,300,'data');

Therefore this query should result in two rows being added, but instead I get the error message.

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger generating Error On INSERT
2490
May 20, 2011 06:48AM


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.