120k views
5 votes
write a script that creates and calls a stored procedure named insert_category. first, code a statement that creates a procedure that adds a new row to the categories table. to do that, this procedure should have one parameter for the category name. code at least two call statements that test this procedure. (note that this table doesn’t allow duplicate category names.)

User Jnorris
by
5.0k points

2 Answers

4 votes

Answer:Write a script that creates and calls a stored function named item_total that calculates the total amount of an item in the Order_Items table (discount price multiplied by quantity).

To do that, this function should accept one parameter for the item ID, it should use the discount_price function that you created in assignment 2, and it should return the value of the total for that item.

Explanation:DROP FUNCTION IF EXISTS item_total;

DELIMITER //

CREATE FUNCTION item_total

(

item_id_param INT(11)

)

RETURNS DECIMAL(10,2)

BEGIN

DECLARE total_amount_var DECIMAL(10,2);

SELECT quantity * DISCOUNT_PRICE(item_id_param)

INTO total_amount_var

FROM order_items

WHERE item_id = item_id_param;

RETURN total_amount_var;

END//

DELIMITER ;

-- Check:

SELECT item_id, discount_price(item_id), quantity,

item_total(item_id)

FROM order_items;

User Redgren Grumbholdt
by
5.1k points
3 votes

Answer:

Sjjssksm

Step-by-step explanation:

User ThreeDots
by
4.9k points