7806_devToTest_2332 #2801

Merged
alexm merged 126 commits from 7806_devToTest_2330 into test 2024-07-30 06:14:09 +00:00
1 changed files with 30 additions and 9 deletions
Showing only changes of commit 2078bf58ff - Show all commits

View File

@ -1,14 +1,35 @@
DELIMITER $$ 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 BEGIN
/**
* Actualiza el volumen de la ruta.
*
* @param vSelf Id ruta
*/
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
UPDATE vn.route r CREATE OR REPLACE TEMPORARY TABLE tRouteVolume
LEFT JOIN ( ENGINE = MEMORY
SELECT routeFk, SUM(volume) AS m3 SELECT IFNULL(SUM(volume), 0) volume
FROM saleVolume FROM saleVolume
WHERE routeFk = vRoute WHERE routeFk = vSelf;
) v ON v.routeFk = r.id
SET r.m3 = IFNULL(v.m3,0) START TRANSACTION;
WHERE r.id =vRoute;
SELECT id FROM `route` WHERE id = vSelf FOR UPDATE;
UPDATE `route`
SET m3 = (SELECT volume FROM tRouteVolume)
WHERE id = vSelf;
COMMIT;
DROP TEMPORARY TABLE tRouteVolume;
END$$ END$$
DELIMITER ; DELIMITER ;