diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index c2e0bc0c1..a12397aa6 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -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 ;