From ba6b6572c38139feb6bce0858a2b6fdbb5824f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Sep 2024 09:45:12 +0200 Subject: [PATCH] fix: collection_new --- db/routines/vn/procedures/collection_new.sql | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 53f5500a0..41f1a1028 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -173,26 +173,24 @@ BEGIN -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede IF vHasUniqueCollectionTime THEN - - SELECT ticketFk INTO vFirstTicketFk - FROM tmp.productionBuffer - ORDER BY HH, - mm, - productionOrder DESC, - m3 DESC, - agency, - zona, - routeFk, - ticketFk - LIMIT 1; - DELETE pb FROM tmp.productionBuffer pb JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk - AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm); - + AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm); END IF; + SELECT ticketFk INTO vFirstTicketFk + FROM tmp.productionBuffer + ORDER BY HH, + mm, + productionOrder DESC, + m3 DESC, + agency, + zona, + routeFk, + ticketFk + LIMIT 1; + OPEN vTickets; l: LOOP SET vDone = FALSE;