How to fix this bug when creating this trigger in MySQL?

Viewed 358

I created two triggers that are almost the same.

The triggers look like this:

Trigger 1

delimiter !!
drop trigger if exists updated_movie !!
create trigger update_movie after update on movie

for each row 

begin

    insert into movie_modification
    values (old.id, old.title, old.id_director, old.year, old.duration, old.country, old.movie_facebook_likes, old.imdb_score, old.gross, old.budget, true);

end !!
delimiter ;

Trigger 2

delimiter !!
drop trigger if exists inserted_movie !!
create trigger inserted_movie after insert on movie

for each row

begin

    insert into movie_modification
    values (new.id_movie, new.title, new.id_director, new.year, new.duration, new.country, new.movie_facebook_likes, new.imdb_score, new.gross, new.budget, false);

end !!
delimiter ;

As I changed some things on the triggers, I had to drop them and create them a couple of times. Now that I have the final format for my triggers I execute all the second trigger (inserted_movies) and it drops and creates again successfully.

But when I execute the first one (updated_movies) I get the following output and error:

0 row(s) affected, 1 warning(s): 1360 Trigger does not exist Error Code: 1359. Trigger already exists

Isn't MySQL contradicting itself? I don't understand why does this happen just to one of the triggers. They are both almost the same.

How can I fix this?

0 Answers
Related