From 22a6c3695c25958fc8c91ecbd19af3d4bfdedac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 22 May 2024 18:05:16 +0200 Subject: [PATCH] feat:concurrency issue refs #6861 --- .../vn/procedures/itemShelvingSale_addBySale.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 3ad581b15..7e836859a 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -37,12 +37,12 @@ proc: BEGIN IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -/* DECLARE EXIT HANDLER FOR SQLEXCEPTION + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; -*/ + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)) INTO vLastPickingOrder, vOutStanding FROM sale s @@ -67,6 +67,8 @@ proc: BEGIN LEAVE l; END IF; + START TRANSACTION; + SELECT id INTO vItemShelvingFk FROM itemShelving WHERE id = vItemShelvingFk @@ -76,7 +78,6 @@ proc: BEGIN SET vOutStanding = vOutStanding - vReservedQuantity; IF vReservedQuantity > 0 THEN - -- START TRANSACTION; INSERT INTO itemShelvingSale( itemShelvingFk, @@ -92,8 +93,9 @@ proc: BEGIN SET available = available - vReservedQuantity WHERE id = vItemShelvingFk; - -- COMMIT; END IF; + + COMMIT; END LOOP; CLOSE vItemShelvingAvailable; END$$