Question: For SQL homework, I ' m working on this question: Write a script that creates and calls a stored function named discount _ price that

For SQL homework, I'm working on this question:
Write a script that creates and calls a stored function named discount_price that calculates the discount price of an item in the Order_Items table (discount amount subtracted from item price). To do that, this function should accept one parameter for the item ID, and it should return the value of the discount price for that item. Execute the query and take a screenshot of the query and the results.
So this is the code I tried, but it doesn't seem to work:
DELIMITER //
CREATE FUNCTION discount_price
(
itemIdParam INT
)
RETURNS DECIMAL(9,2)
BEGIN
DECLARE varDiscountPrice DECIMAL(9,2);
SELECT item_price-discount_amount
INTO varDiscountPrice
FROM Order_Items
WHERE itemId= itemIdParam;
RETURN varDiscountPrice;
END//
DELIMITER;
and the error I also got is also attached. Did I perform a coding error or is my solution incorrect?
For SQL homework, I ' m working on this question:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!