22 lines
555 B
MySQL
22 lines
555 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`CompresTriggerBeforeDelete`(oldId INT, oldEntrada INT)
|
||
|
BEGIN
|
||
|
|
||
|
DECLARE hasToRecalculate BOOLEAN;
|
||
|
DECLARE newWarehouse INT;
|
||
|
|
||
|
SELECT Id_Compra INTO hasToRecalculate FROM vn.lastBuy lb
|
||
|
WHERE lb.id = oldId LIMIT 1;
|
||
|
|
||
|
IF hasToRecalculate THEN
|
||
|
SELECT warehouse_id INTO newWarehouse FROM travel t
|
||
|
JOIN Entradas e ON t.id = e.travel_id
|
||
|
WHERE e.Id_Entrada = oldEntrada;
|
||
|
|
||
|
CALL vn.lastBuyRefresh(newWarehouse);
|
||
|
END IF;
|
||
|
|
||
|
|
||
|
END$$
|
||
|
DELIMITER ;
|