Question: -- Create the stored function DELIMITER // CREATE FUNCTION discount_price(item_id INT) RETURNS DECIMAL(10, 2) DETERMINISTIC BEGIN DECLARE item_price DECIMAL(10, 2); DECLARE discount_amount DECIMAL(10, 2); DECLARE

-- Create the stored function DELIMITER // CREATE FUNCTION discount_price(item_id INT) RETURNS DECIMAL(10, 2) DETERMINISTIC BEGIN DECLARE item_price DECIMAL(10, 2); DECLARE discount_amount DECIMAL(10, 2); DECLARE discounted_price DECIMAL(10, 2); -- Get the item price and discount amount from the Order_Items table SELECT price, discount INTO item_price, discount_amount FROM Order_Items WHERE item_id = item_id; -- Calculate the discounted price SET discounted_price = item_price - discount_amount; RETURN discounted_price; END // DELIMITER ; -- Call the stored function SELECT discount_price(123) AS discounted_price_for_item_123;

is what I have for an assignment, however my call function receives an error of 'price' column does not exist. what am i doing wrong?

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 Databases Questions!