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, Im working on this question:
Write a script that creates and calls a stored function named discountprice that calculates the discount price of an item in the OrderItems 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 discountprice
itemIdParam INT
RETURNS DECIMAL
BEGIN
DECLARE varDiscountPrice DECIMAL;
SELECT itempricediscountamount
INTO varDiscountPrice
FROM OrderItems
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?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
