This commit is contained in:
Guillermo Bonet 2024-07-05 08:38:40 +02:00
parent 6f0196d656
commit 50c9ded103
1 changed files with 4 additions and 3 deletions

View File

@ -34,7 +34,8 @@ BEGIN
END IF;
-- Calcula el ultimo dia de vida para cada producto
CREATE OR REPLACE TEMPORARY TABLE tItemRange
-- Tiene tmp a propósito, porque si no falla al utilizarlo en el WITH
CREATE OR REPLACE TEMPORARY TABLE tmp.itemRange
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT i.id itemFk,
@ -206,7 +207,7 @@ BEGIN
NULL
FROM hedera.orderRow r
JOIN hedera.`order` o ON o.id = r.orderFk
JOIN tItemRange ir ON ir.itemFk = r.itemFk
JOIN tmp.itemRange ir ON ir.itemFk = r.itemFk
JOIN vn.client c ON c.id = o.customer_id
WHERE r.shipment >= vDateInventory
AND (ir.ended IS NULL OR r.shipment <= ir.ended)
@ -308,6 +309,6 @@ BEGIN
DROP TEMPORARY TABLE
tItemDiary,
tItemRange;
tmp.itemRange;
END$$
DELIMITER ;