salix/db/routines/vn/procedures/route_updateM3.sql

19 lines
367 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(
vSelf INT
)
BEGIN
/**
* Actualiza el volumen de la ruta.
*
* @param vSelf Id ruta
*/
DECLARE vVolume DECIMAL(10,1)
DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf);
UPDATE `route`
SET m3 = IFNULL(vVolume, 0)
WHERE id = vSelf;
END$$
DELIMITER ;