salix/db/routines/vn2008/triggers/Conteo_afterInsert.sql

15 lines
545 B
MySQL
Raw Normal View History

DELIMITER $$
2024-01-25 16:33:54 +00:00
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`Conteo_afterInsert`
AFTER INSERT ON `Conteo`
FOR EACH ROW
BEGIN
DECLARE intTravel INTEGER;
SELECT t.id INTO intTravel FROM Compres c JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
JOIN travel t ON t.id = e.travel_id
WHERE landing = util.VN_CURDATE() AND c.Id_Article = NEW.Id_Article AND warehouse_id = NEW.warehouse_id AND received <> TRUE LIMIT 1;
IF (intTravel) then
UPDATE travel SET received = TRUE WHERE id = intTravel;
END IF;
END$$
DELIMITER ;