Why does not UPDATE make me

0

I am trying to Create a Trigger for MYSQL but it does NOT leave me Insert in table or update (Note: And installed the trigger from Navicat I do NOT know if I have something to do but I do the query to create the triger Success if it leaves me BUT if I do it from phpmyadmin the result is the third query and also does not allow editing) somebody help me please? the error that comes to me is that of the image

CREATE TRIGGER Actualize_Nombres
AFTER INSERT, UPDATE
ON sr_escalas_detalle FOR EACH ROW

BEGIN


SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto1);
SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto2);
SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto3);
SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto4);
SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto5);

SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto1);
SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto2);
SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto3);
SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto4);
SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto5);

SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto1);
SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto2);
SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto3);
SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto4);
SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto5);


UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto1 = New.id_producto1;
UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto2 = New.id_producto2;
UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto3 = New.id_producto3;
UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto4 = New.id_producto4;
UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto5 = New.id_producto5;

END

Same edited query follows with the error of the image:

CREATE TRIGGER Actualize_Nombres
AFTER INSERT
ON sr_escalas_detalle FOR EACH ROW

BEGIN

SET @titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto1);
SET @titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto1);
SET @titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto1);


UPDATE 'sr_escalas_detalle' SET  titulo_esp = @titulo_esp,titulo_eng = @titulo_eng,titulo_bra = @titulo_bra ,descripcion_esp = '<br>',descripcion_eng = '<br>',descripcion_bra = '<br>' WHERE New.id_producto1 = New.id_producto1;

END

3 Created from phpmyadmin After returning to edit, try this Query and discard but still not insert records. if I install it from navicat it lets install but it does not insert records and if I do it from phpMyAdmin it DOES NOT let create the trigger and of course without the trigger if it inserts data.

DELIMITER //

CREATE TRIGGER Actualize_Nombres
AFTER INSERT
ON sr_escalas_detalle FOR EACH ROW
BEGIN

UPDATE 'sr_escalas_detalle' SET  
titulo_esp = (SELECT nombre_esp FROM sr_productos WHERE id = New.id_producto1 LIMIT 1),
titulo_eng = (SELECT nombre_eng FROM sr_productos WHERE id = New.id_producto1 LIMIT 1),
titulo_bra = (SELECT nombre_bra FROM sr_productos WHERE id = New.id_producto1 LIMIT 1),
descripcion_esp = '<br>',
descripcion_eng = '<br>',
descripcion_bra = '<br>' 
WHERE New.id_producto1 = New.id_producto1;




END; //

DELIMITER ;

PD I try to insert this:

INSERT INTO 'sr_escalas_detalle' ('id', 'id_escala', 'orden', 'puntos', 'id_producto1', 'id_producto2', 'id_producto3', 'id_producto4', 'id_producto5', 'titulo_esp', 'titulo_eng', 'titulo_bra', 'descripcion_esp', 'descripcion_eng', 'descripcion_bra') VALUES ('1', '1', '1', '110000', '1', '0', '0', '0', '0', NULL, NULL, NULL, NULL, NULL, NULL);

The structure of the table is as follows:

CREATE TABLE 'sr_escalas_detalle' (
  'id' int(10) NOT NULL AUTO_INCREMENT,
  'id_escala' int(10) NOT NULL,
  'orden' int(10) NOT NULL,
  'puntos' int(10) NOT NULL,
  'id_producto1' int(10) NOT NULL,
  'id_producto2' int(10) NOT NULL,
  'id_producto3' int(10) NOT NULL,
  'id_producto4' int(10) NOT NULL,
  'id_producto5' int(10) NOT NULL,
  'titulo_esp' varchar(255) DEFAULT NULL,
  'titulo_eng' varchar(255) DEFAULT NULL,
  'titulo_bra' varchar(255) DEFAULT NULL,
  'descripcion_esp' varchar(3000) DEFAULT NULL,
  'descripcion_eng' varchar(3000) DEFAULT NULL,
  'descripcion_bra' varchar(3000) DEFAULT NULL,
  PRIMARY KEY ('id')
)
    
asked by Juan Carlos Villamizar Alvarez 23.10.2018 в 01:40
source

1 answer

0

The answer I did not know is that a trigger does not update the same table that is affected

    
answered by 16.11.2018 / 16:29
source