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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started