Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6964335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:43+00:00 2026-05-27T15:54:43+00:00

I have the same trigger on two tables. The first one: CREATE TRIGGER updateURL1

  • 0

I have the same trigger on two tables.

The first one:

CREATE TRIGGER updateURL1 AFTER UPDATE ON table1
FOR EACH ROW
BEGIN
    UPDATE table2 SET url=NEW.url WHERE uname=NEW.uname;
END;

The second one:

CREATE TRIGGER updateURL2 AFTER UPDATE ON table2
FOR EACH ROW
BEGIN
    UPDATE table1 SET url=NEW.url WHERE uname=NEW.uname;
END;

As I expected, it tries to do an infinite loop, what is obvious. But, good for me, it doesn’t make it because an error is triggered because it cannot update the table just updated.

The problem, I’m using a php form to edit the url of a user and many other informations. If mysql triggers an error, I write it on the page.

The question, is there a way to tell mysql not to trigger an error for that procedure only?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:54:43+00:00Added an answer on May 27, 2026 at 3:54 pm

    You can declare a handler for the error that ignores it.

    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
    

    This is how you use it in a trigger (and I’ve just tried it)

    DROP TRIGGER updateURL1;
    DROP TRIGGER updateURL2;
    
    DELIMITER //
    CREATE TRIGGER updateURL1 AFTER UPDATE ON table1
    FOR EACH ROW
    BEGIN       
        DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
        UPDATE table2 SET url=NEW.url WHERE uname=NEW.uname;
    END//
    
    CREATE TRIGGER updateURL2 AFTER UPDATE ON table2
    FOR EACH ROW
    BEGIN
        DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
        UPDATE table1 SET url=NEW.url WHERE uname=NEW.uname;
    END//
    
    DELIMITER ;
    

    Edit: I’ve thought of another way. You use an global session variable like this:

    DROP TRIGGER updateURL1;
    DROP TRIGGER updateURL2;
    
    DELIMITER //
    CREATE TRIGGER updateURL1 AFTER UPDATE ON table1
    FOR EACH ROW
    BEGIN       
      IF @protector IS NULL THEN
        SET @protector=1;
        UPDATE table2 SET url=NEW.url WHERE uname=NEW.uname;
        SET @protector=null;
      END IF;
    END//
    
    CREATE TRIGGER updateURL2 AFTER UPDATE ON table2
    FOR EACH ROW
    BEGIN
      IF @protector IS NULL THEN
        SET @protector=1;
        UPDATE table1 SET url=NEW.url WHERE uname=NEW.uname;
        SET @protector=null;
      END IF;
    END//
    
    DELIMITER ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two servers, the first one with SQL Server 2005 and the second
I have two tables, that share the same definition. I commonly insert new objects
I have two tables in the same DB on SQL Server 2008. When I
I have two tables, tableA and tableB. I want to set a trigger. Once
Let's say I have two Databases like so : DatabaseA create table Table1 (
I have two tables CrossDBTrigTest_1 and CrossDBTrigTest_2 on same SQL Server instance. The databases
Can we have same delegate for two events ? which have same number of
I have two tables (some so-called dictionaries, only about ~50 entries I presume) that
I have some code that disables a trigger on a table, runs an update,
I have two tables called TableA and TableB. TableA has the following fields: TableA_ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.