Professional Documents
Culture Documents
Lab 7
Lab 7
Objective
The goal of this lab is to introduce you to stored procedures. You will be creating a few
stored procedures that will allow users to create, update and delete order details in the
Northwind database. These stored procedures will enforce some simple business logic.
Resources
The example stored procedures get_Order Details_1 and update_Order Details_1 found
in the file SprocExamples.txt (in the Lab Instructions folder on Angel) provide
examples of coding conventions, validating parameters, raising errors, and appropriate
comments.
Turn in Instructions
Place your .sql files for creating your stored procedures in a .rar (or .zip). Also include a
text file named who.txt listing you and your partner’s names. Place your archive in
the Lab 7 drop box.
CSSE333 Introduction to Databases – Lab Assignment
Assignment Details
1) In your copy of Northwind, you will first create basic frameworks for the stored
procedures. You can do this either by using the Create Procedure Basic Template
in the Template Explorer(View> Template Explorer) within Server Management
Studio or by using the following queries:
Your task is to refine the stored procedure to meet the following additional
requirements:
a. Make the UnitPrice and Discount parameters optional, using the technique
discussed in the previous task.
b. If no UnitPrice is given, then use the UnitPrice value from the product
table.
c. If no Discount is given, then use a discount of 0.
d. Adjust the quantity in stock for the product by subtracting the quantity
sold from inventory.
e. However, if there is not enough of a product in stock, then abort the stored
procedure without making any changes to the database.
f. Print a message if the quantity in stock of a product drops below its
Reorder Level as a result of the update.
In addition to satisfying the functional requirements above, make sure that your
stored procedure is well documented, validates parameters, and returns
appropriate result codes as in the previous tasks.
5) Complete the anonymous feedback for Lab 7 on Angel.
Turn in Instructions
Place your .sql files for creating your stored procedures in a .rar (or .zip). Also include a
text file named who.txt listing you and your partner’s names. Place your archive in
the Lab 7 drop box.
Revision History