feat: refs #7681 Optimization and refactor #2707
|
@ -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
|
||||
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 ;
|
||||
|
|
Loading…
Reference in New Issue
No es necesario generar un tabla, solo es una variable