19 lines
515 B
SQL
19 lines
515 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`EntradasTriggerBeforeDelete`(oldTravel INT, oldId INT)
|
|
BEGIN
|
|
|
|
DECLARE hasToRecalculate BOOLEAN;
|
|
DECLARE newWarehouse INT;
|
|
|
|
SELECT Id_Compra INTO hasToRecalculate FROM Compres c
|
|
JOIN vn.lastBuy lb ON lb.id = c.Id_Compra
|
|
WHERE c.Id_Entrada = newId LIMIT 1;
|
|
IF hasToRecalculate THEN
|
|
SELECT warehouse_id INTO newWarehouse FROM travel WHERE id = oldTravel;
|
|
CALL vn.lastBuyRefresh(newWarehouse);
|
|
END IF;
|
|
|
|
|
|
END$$
|
|
DELIMITER ;
|