Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-- 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago