salix/db/changes/10050-pentecostes/01-routeUpdateM3.sql

18 lines
324 B
MySQL
Raw Normal View History

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 ;