feat: refs #7681 Optimization and refactor #2707

Merged
guillermo merged 7 commits from 7681-routeUpdateM3 into dev 2024-07-19 11:12:22 +00:00
1 changed files with 13 additions and 9 deletions

View File

@ -1,14 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(vRoute INT)
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)
guillermo marked this conversation as resolved Outdated

No es necesario generar un tabla, solo es una variable

No es necesario generar un tabla, solo es una variable
DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf);
UPDATE vn.route r
LEFT JOIN (
SELECT routeFk, SUM(volume) AS m3
FROM saleVolume
WHERE routeFk = vRoute
) v ON v.routeFk = r.id
SET r.m3 = IFNULL(v.m3,0)
WHERE r.id =vRoute;
UPDATE `route`
SET m3 = IFNULL(vVolume, 0)
WHERE id = vSelf;
END$$
DELIMITER ;