After an Inventory Allocation has been created, Partners need to be chosen. Thus, we cannot fill in the value of Total Served in the Inventory Allocation table until we've chosen all our partners. The value is calculated and stored because it is used frequently in the distribution algorithm.
<?php
--
-- Inventory Allocation Count Total Served Stored Procedure
--
USE `cics_app`;
DROP PROCEDURE IF EXISTS Ia_CountTotalServed;
DELIMITER |
CREATE PROCEDURE Ia_CountTotalServed (IN ia_id INT)
BEGIN
DECLARE total_served INT;
SELECT
SUM(`net_served`) INTO total_served
FROM
`ia_partner`
WHERE
`ia_partner`.`ia_id` = ia_id;
SELECT total_served;
END;
|
DELIMITER ;
?>

Post new comment