USE `hedera`;
DROP procedure IF EXISTS `orderAddItem`;

DELIMITER $$
USE `hedera`$$
CREATE DEFINER=`root`@`%` PROCEDURE `orderAddItem`(
	vWarehouse INT,
    vItem INT,
    vAmount INT,
    vOrder INT)
BEGIN
	DECLARE vDate DATE;
    DECLARE vAddress INT;
    DECLARE vAgencyMode INT;
    
    SELECT date_send, address_id, agency_id
		INTO vDate, vAddress, vAgencyMode
		FROM `order`
        WHERE id = vOrder;

	CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);

	CALL addItem(vWarehouse, vItem, vAmount, vOrder);
END$$

DELIMITER ;

