31 lines
988 B
SQL
31 lines
988 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
|
|
BEGIN
|
|
|
|
SELECT ish.itemFk,
|
|
ish.longName,
|
|
ish.size,
|
|
ish.subName,
|
|
ish.itemShelvingFk,
|
|
ish.shelving,
|
|
ish.stock,
|
|
LEAST(ish.stock,quantity) as total,
|
|
CONCAT(
|
|
CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
|
|
' x ',
|
|
ish.packing,
|
|
IF (
|
|
LEAST(ish.stock,quantity) MOD ish.packing,
|
|
CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
|
|
''
|
|
),
|
|
' = ',
|
|
LEAST(ish.stock,quantity)
|
|
) as proposal
|
|
FROM vn.itemShelvingPlacementSupplyStock ish
|
|
WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci
|
|
AND ish.itemFk = vItemFk;
|
|
|
|
END$$
|
|
DELIMITER ;
|