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

24 lines
468 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(
vSelf INT
)
BEGIN
/**
* Actualiza el volumen de la ruta.
*
* @param vSelf Id ruta
*/
CREATE OR REPLACE TEMPORARY TABLE tRouteVolume
ENGINE = MEMORY
SELECT IFNULL(SUM(volume), 0) volume
FROM saleVolume
WHERE routeFk = vSelf;
UPDATE `route`
SET m3 = (SELECT volume FROM tRouteVolume)
WHERE id = vSelf;
DROP TEMPORARY TABLE tRouteVolume;
END$$
DELIMITER ;