Question: Exercises 1 . Write a script that creates and calls a stored procedure named insert _ category. First, code a statement that creates a procedure
Exercises
Write a script that creates and calls a stored procedure named insertcategory. 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.
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.
Write a script that creates and calls a stored function named itemtotal that calculates the total amount of an item in the OrderItems table discount price multiplied by quantity To do that, this function should accept one parameter for the item ID it should use the discountprice function that you created in exercise and it should return the value of the total for that item.
Write a script that creates and calls a stored procedure named insertproduct that inserts a row into the Products table. This stored procedure should accept five parameters, one for each of these columns: categoryid productcode, productname, listprice, and
discountpercent. This stored procedure should set the description column to an empty string, and it should set the dateadded column to the current date. If the value for the listprice column is a negative number, the stored procedure should raise an
error that indicates that this column doesn't accept negative numbers. Similarly, the procedure should raise an error if the value for the discountpercent column is a negative number.
Code at least two CALL statements that test this procedure.
Write a script that creates and calls a stored procedure named updateproductdiscount that updates the discountpercent column in the Products table. This procedure should have one parameter for the product ID and another for the discount percent.
If the value for the discountpercent column is a negative number, the stored procedure should raise an error that the value for this column must be a positive number. Code at least two CALL statements that test this procedure.
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
