salix/db/routines/stock/procedures/inbound_removePick.sql

21 lines
449 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_removePick`(
vSelf INT,
vOutboundFk INT,
vQuantity INT,
vTotalQuantity INT
)
BEGIN
IF vQuantity < vTotalQuantity THEN
UPDATE inboundPick
SET quantity = quantity - vQuantity
WHERE inboundFk = vSelf
AND outboundFk = vOutboundFk;
ELSE
DELETE FROM inboundPick
WHERE inboundFk = vSelf
AND outboundFk = vOutboundFk;
END IF;
END$$
DELIMITER ;