MySQL Forums
Forum List  »  Triggers

ERROR 1064 (42000) with triggers
Posted by: mahmoud ahmadinejad
Date: December 11, 2011 12:48PM


I have a table named country

in this table there is the columns name, capital, code, old_capital, datechanged

i have to make a trigger that will add to old_capital the old name of the capital, and in datechanged the date when the modification happened

I have made this trigger:
delimiter |

CREATE TRIGGER change_capital before UPDATE ON country
FOR each ROW
INSERT INTO country (anciennecap) VALUES (OLD.Capital);
INSERT INTO country (datechange) VALUES (NOW());

but it shows me the error:
ERROR 1442 (HY000): Can't update table 'country' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

I do not understand my mistake. Can anyone help me out?

Thank you

Options: ReplyQuote

Written By
ERROR 1064 (42000) with triggers
December 11, 2011 12:48PM
December 11, 2011 01:58PM
December 11, 2011 02:59PM
December 11, 2011 05:02PM

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.