I have a problem when creating a trigger
in phpmyadmin
. This is my syntax in the definition field:
DECLARE n_ubicacion VARCHAR(45) DEFAULT '';
IF (OLD.id_ubicacion <> NEW.id_ubicacion) THEN
SELECT ubicacion INTO n_ubicacion FROM ubicacions WHERE id = NEW.id_ubicacion LIMIT 1;
END IF;
INSERT INTO historico_equipos(usuario, id_equipo, estado, ubicacion, empleado, f_asignacion, created_at) VALUES (CURRENT_USER(), NEW.id, NEW.id_estado, n_ubicacion, NEW.id_empleado, NEW.f_asignacion, CURRENT_DATE())
I can not find where the problem is. In phpmyadmin the following error appears:
Something is wrong in my syntax near:
DECLARE n_ubicacion VARCHAR(45) DEFAULT ''; IF (OLD.id_ubicacion <> NEW.id_ubicacion) THEN