Answer:Write a script that creates and calls a stored function named item_total that calculates the total amount of an item in the Order_Items table (discount price multiplied by quantity).
To do that, this function should accept one parameter for the item ID, it should use the discount_price function that you created in assignment 2, and it should return the value of the total for that item.
Explanation:DROP FUNCTION IF EXISTS item_total;
DELIMITER //
CREATE FUNCTION item_total
(
item_id_param INT(11)
)
RETURNS DECIMAL(10,2)
BEGIN
DECLARE total_amount_var DECIMAL(10,2);
SELECT quantity * DISCOUNT_PRICE(item_id_param)
INTO total_amount_var
FROM order_items
WHERE item_id = item_id_param;
RETURN total_amount_var;
END//
DELIMITER ;
-- Check:
SELECT item_id, discount_price(item_id), quantity,
item_total(item_id)
FROM order_items;