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 ;
