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//

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.