0% found this document useful (0 votes)
29 views1 page

Lab5A - Stored Procedures

The document describes 9 stored procedures and functions to be created in the "ProductOrders" database. The procedures include: 1) showing all customer details, 2) showing encrypted customer details, 3) showing orders for a given customer ID, 4) counting orders for a given customer ID, 5) error handling, 6) using OPENQUERY, 7) displaying, counting, and totaling orders for a given customer, 8) calculating a total order amount, and 9) listing products bought by a given customer.

Uploaded by

minh nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Lab5A - Stored Procedures

The document describes 9 stored procedures and functions to be created in the "ProductOrders" database. The procedures include: 1) showing all customer details, 2) showing encrypted customer details, 3) showing orders for a given customer ID, 4) counting orders for a given customer ID, 5) error handling, 6) using OPENQUERY, 7) displaying, counting, and totaling orders for a given customer, 8) calculating a total order amount, and 9) listing products bought by a given customer.

Uploaded by

minh nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Stored Procedures

In the database “ProductOrders” created in the previous exercise, create the following stored
procedures or functions:

1. Stored procedure for showing the details of all customers.


2. Stored procedure for showing the details of all customers by using “with encryption” option
3. Stored procedure for showing the list of orders of a given customer where CustomerID is an input parameter
of the procedure.
4. Stored procedure for calculating the number of orders of a given customer where CustomerID is an input
parameter of the procedure and NumberOfOrder is the output parameter of the procedure.
5. Write an example using TRY...CATCH for handling errors.
6. Write an example using stored procedure in a query using OPENQUERY
7. Stored procedure having CustomerID as an input parameter:
a. Display the list (OrderID, OrderDate, ProductCode, ProductName, Quantity, SellPrice) of a given
customer
b. Calculate the total amount of all orders of the given customer and return as an output parameter.
c. Calculate the number of orders of the given customer and return as an output parameter.
8. Function for calculating the total amount of an order, where orderID is an input parameter of the function
and TotalAmount is the returning value of the function.
9. Function returning the list (ProductCode, ProducttName, TotalQuantity) of all products that a customer
bought, where CustomerID is the input parameter of the function.

You might also like