From eaca3427772d8c02d6ccc5ad600b2fb075d67dd4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 14:11:55 +0200 Subject: [PATCH] refactor: refs #7662 Minor change --- db/routines/vn/procedures/collection_new.sql | 1 + .../ticket_splitItemPackingType.sql | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index cd4b1b47f..029427306 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -229,6 +229,7 @@ BEGIN AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk); + DROP TEMPORARY TABLE tmp.ticketIPT; UPDATE tmp.productionBuffer pb JOIN ( diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 2a84948c9..87fbafe13 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -60,17 +60,17 @@ BEGIN FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; - CREATE OR REPLACE TEMPORARY TABLE tTicketIPT( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) ) ENGINE = MEMORY; CASE vPackingTypesToSplit WHEN 0 THEN - INSERT INTO tTicketIPT(ticketFk, itemPackingTypeFk) + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vSelf, vItemPackingTypeFk); WHEN 1 THEN - INSERT INTO tTicketIPT(ticketFk, itemPackingTypeFk) + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) SELECT vSelf, itemPackingTypeFk FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; @@ -78,7 +78,7 @@ BEGIN OPEN vSaleGroup; FETCH vSaleGroup INTO vItemPackingTypeFk; - INSERT INTO tTicketIPT(ticketFk, itemPackingTypeFk) + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vSelf, vItemPackingTypeFk); l: LOOP @@ -91,7 +91,7 @@ BEGIN CALL ticket_Clone(vSelf, vNewTicketFk); - INSERT INTO tTicketIPT(ticketFk, itemPackingTypeFk) + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vNewTicketFk, vItemPackingTypeFk); END LOOP; @@ -100,13 +100,13 @@ BEGIN SELECT s.id FROM sale s JOIN tSale ts ON ts.id = s.id - JOIN tTicketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk WHERE s.ticketFk = vSelf FOR UPDATE; UPDATE sale s JOIN tSale ts ON ts.id = s.id - JOIN tTicketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk SET s.ticketFk = t.ticketFk; SELECT itemPackingTypeFk INTO vItemPackingTypeFk @@ -117,7 +117,7 @@ BEGIN UPDATE sale s JOIN tSale ts ON ts.id = s.id - JOIN tTicketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk SET s.ticketFk = t.ticketFk WHERE ts.itemPackingTypeFk IS NULL; END CASE; @@ -126,7 +126,6 @@ BEGIN DROP TEMPORARY TABLE tSale, - tSaleGroup, - tTicketIPT; + tSaleGroup; END$$ DELIMITER ;