
DROP procedure IF EXISTS `vn`.`routeUpdateM3`;

DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT)
BEGIN

	UPDATE vn.route r
		JOIN (SELECT routeFk, SUM(volume) AS m3
					FROM ticketGetVolume    
					WHERE routeFk = vRoute
			 ) v ON v.routeFk = r.id
		SET r.m3 = v.m3;
END$$

DELIMITER ;

