What's wrong with this Trigger? of MySQL

0

I GIVE ME ERROR of Sintexis, I'm doing it the same as I think it's done with SQL server 2008 R2 but I do it for MySQL. What is the error? If someone helps me, I thank you in advance.

CREATE TRIGGER Actualize_Nombres
AFTER INSERT
ON sr_escalas_detalle FOR EACH ROW

BEGIN

DECLARE 
@id INT,
@id_escala INT,
@orden  INT,
@puntos INT,
@id_producto1 INT,
@id_producto2 INT,
@id_producto3 INT,
@id_producto4 INT,
@id_producto5 INT,
@titulo_esp varchar (max),
@titulo_eng varchar (max),
@titulo_bra varchar (max),
@descripcion_esp varchar (max),
@descripcion_eng varchar (max),
@descripcion_bra varchar (max)


SET @id_producto1 = (SELECT id_producto1 FROM INSERTED)
SET @id_producto2 = (SELECT id_producto2 FROM INSERTED)
SET @id_producto3 = (SELECT id_producto3 FROM INSERTED)
SET @id_producto4 = (SELECT id_producto4 FROM INSERTED)
SET @id_producto5 = (SELECT id_producto5 FROM INSERTED)

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

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

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


UPDATE 'shaiyar1_almacen'.'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 id_producto1 = @id_producto1
UPDATE 'shaiyar1_almacen'.'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 id_producto2 = @id_producto2
UPDATE 'shaiyar1_almacen'.'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 id_producto3 = @id_producto3
UPDATE 'shaiyar1_almacen'.'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 id_producto4 = @id_producto4
UPDATE 'shaiyar1_almacen'.'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 id_producto5 = @id_producto5

END
    
asked by Juan Carlos Villamizar Alvarez 23.10.2018 в 00:40
source

1 answer

1

In the First Part it was

SET @Variable = 'sentencia'

in the second serious answer:

the value of INSERTED in SQL server is equal to New.Variable in MySQL

    
answered by 23.10.2018 / 01:38
source