BCS 360 Study Guide - Midterm Guide: Stored Procedure
Document Summary
Assignment three: write a script that creates and calls a stored procedure named spinsertcategory. 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 exec statements that test this procedure. (note that this table doesn t allow duplicate category names. ) - test fail: (cannot insert duplicate key in object "dbo. categories". Exec spinsertcategory "violins": write a script that creates and calls a function named fnitemtotal 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 fndiscountprice function that you created in exercise 2, and it should return the value of the total for that item. Return (select (itemprice - discountamount) as discountprice from orderitems. - check: select itemid, dbo. fndiscountprice(itemid) as discountprice, dbo. fnitemtotal(itemid) as.