MySQL error code 1235

前端 未结 2 1767
礼貌的吻别
礼貌的吻别 2020-12-17 11:09

In MySQL I tried to define a trigger like this:

DELIMITER $$  
CREATE TRIGGER vipInvite  
AFTER INSERT ON meetings  
         


        
相关标签:
2条回答
  • 2020-12-17 11:12

    This error means you already have an AFTER INSERT trigger on meetings table.

    If it is the same trigger (meaning vipInvite) that you created earlier and now you want to replace it then you need to drop it first

    DROP TRIGGER vipInvite;
    DELIMITER $$  
    CREATE TRIGGER vipInvite
    ...
    END$$
    DELIMITER ;
    

    Now if you have some other trigger you have to merge code from both triggers into one, then drop existing trigger, and then create a new one.

    To show the list of existing triggers use SHOW TRIGGERS.

    SHOW TRIGGERS WHERE `table` = 'meetings';
    
    0 讨论(0)
  • 2020-12-17 11:22

    How to reproduce this error in MySQL:

    ERROR 1235 (42000): This version of MySQL doesn't yet support 'multiple 
    triggers with the same action time and event for one table'
    

    Run the following queries:

    DELIMITER //
    CREATE TRIGGER mytrigger1 AFTER INSERT ON mytable
    FOR EACH ROW
    BEGIN
    END//
    
    DELIMITER //
    CREATE TRIGGER mytrigger2 AFTER INSERT ON mytable
    FOR EACH ROW
    BEGIN
    END//
    

    If you want to hook more than one action onto the same event/table, you will have to cram all of it into one trigger. You could call many stored procedures like this:

    DELIMITER //
    CREATE TRIGGER mytrigger1 AFTER INSERT ON mytable
    FOR EACH ROW
    BEGIN
        CALL fromulate_the_moobars(NEW.myid);
        CALL its_peanut_butter_jelly_time(NEW.myname);
    END//
    
    0 讨论(0)
提交回复
热议问题