Please help me with this problem Err # 1235

0

First of all a big greeting, my problems are this:

I have two different "secondary" tables linked to a "main" table, which I want to update when a record is inserted in the main one. This is my code:

INSERT INTO Secundaria1 (a1, a2, P_ID) VALUES 
(new.Valor1,new.Valor2,new.ID_PRINCIPAL);
INSERT INTO Secundaria2 (a1, a2, a3, P_ID) VALUES 
(new.Valor1,new.Valor2, 0 ,new.ID_PRINCIPAL);

The problem comes when in PhpmyAdmin, in the graphical interface I try to make those two insert inside a trigger, it tells me: "This version of mariaDB does not support 'multiple triggers for the same event' yet"

Googleando I saw that several people were solved the problem using "delimiter" so I got into the SQL tab and put this code:

delimiter 

CREATE TRIGGER update_secundarias AFTER INSERT ON Principal
FOR EACH ROW 
BEGIN
INSERT INTO Secundaria1 (a1, a2, P_ID) VALUES 
(new.Valor1,new.Valor2,new.ID_PRINCIPAL);
INSERT INTO  Secundaria2 (a1, a2, a3 , P_ID) 
VALUES (new.Valor1,new.Valor2, 0 ,new.ID_PRINCIPAL);

END;

delimiter ;

Now the blessed phpmyadmin says to me: Sorry an unexpected error happened!

Would you help me please?

    
asked by David Magnum 01.03.2018 в 20:02
source

1 answer

0

You have to define what the delimiter will be:

DELIMITER $$
CREATE TRIGGER 'update_secundarias' AFTER INSERT ON 'Principal' 

FOR EACH ROW 
BEGIN

INSERT INTO Secundaria1(a1, a2, P_ID) VALUES(new.Valor1,new.Valor2,new.ID_PRINCIPAL);
INSERT INTO Secundaria2(a1, a2, a3 , P_ID) VALUES(new.Valor1,new.Valor2,0,new.ID_PRINCIPAL);

END;$$
DELIMITER ;
    
answered by 29.10.2018 в 01:07