diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 8f23ebe4a..1c3ef06ab 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -16,6 +16,7 @@ BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -33,8 +34,8 @@ BEGIN pc.collectionAssignLockname INTO vHasTooMuchCollections, vLockName - FROM tCollection - JOIN productionConfig pc; + FROM productionConfig pc + LEFT JOIN tCollection ON TRUE; DROP TEMPORARY TABLE tCollection; @@ -53,6 +54,10 @@ BEGIN vItemPackingTypeFk ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); + END IF; + -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk