Question: creating a sql for the guitar shop You will use SQL and My Guitar Shop database to create SQL statements. Save your select statements as
creating a sql for the guitar shop You will use SQL and My Guitar Shop database to create SQL statements.
Save your select statements as a script. Place the semicolon at the end of each SQL statement.
Please number your answers from to in your script and comment out each number. As well include your name and student number as a comment at the top of your script.
Name your script CompAssignmentYourName.
Please submit your script file by uploading it through Brightspace.
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. Include exception handling block.
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.
Code a SELECT statement that tests this function.
Create a trigger named productsbeforeupdate that checks the new value for the discountpercent column of the Products table. This trigger should raise an appropriate error if the discount percent is greater than or less than
If the new discount percent is between and this trigger should modify the new discount percent by multiplying it by That way, a discount percent of becomes
Test this trigger with an appropriate UPDATE statement.
Create a trigger named products before insert that inserts the current date for the date added column 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. Include exception handling block.
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.
Code a SELECT statement that tests this function.
Create a trigger named productsbeforeupdate that checks the new value for the discountpercent column of the Products table. This trigger should raise an appropriate error if the discount percent is greater than or less than
If the new discount percent is between and this trigger should modify the new discount percent by multiplying it by That way, a discount percent of becomes
Test this trigger with an appropriate UPDATE statement.
Create a trigger named productsbeforeinsert that inserts the current date for the dateadded column of the Products table if the value for that column is null.
Test this trigger with an appropriate INSERT statement.
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
