Jump to content

changes to multiple tables with one trigger.


attaboy

Recommended Posts

MySQL version 5.5.16

 

When I run this code I create a trigger on one table that makes updates to 2 other tables whenever I change the code column on the first table.  It works fine for me but I gave this code to a friend and when she tries it she gets an error message back saying that her version of MySQL  won't support changes to multiple tables from a single trigger.  We both installed MySQL around the same time she uses wamp I use xampp.  Is it possible this could be fixed by changing an ini setting?

 
delimiter //
mysql> CREATE TRIGGER
    -> CodeChange_au
    -> AFTER UPDATE
    -> on country
    -> FOR EACH ROW
    -> BEGIN
    ->   set @code_new = NEW.Code;
    ->   set @code_old = OLD.Code;
    ->   UPDATE city SET CountryCode = @code_new
    ->   WHERE CountryCode = @code_old;
    ->   UPDATE CountryLanguage SET CountryCode = @code_new
    ->   WHERE CountryCode = @code_old;
    -> END//

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.