Assignment 4 - Stored Functions
Objectives
To write a stored function that can be used in Queries and Stored Procedures
Assignment
You will be writing 2 stored functions for this assignment. One functions will be a table valued function (they will return a set of values), the other will be a Scalar function.
Function 1: func_GetMenuItemsForMenu - For this function you will pass the ID of the menu to the function. The function will find all MenuItems that are on the menu. It will return a table.
Function 2: func_GetMenuItemDescriptionForMenuItemID - This will operate as expected in the title. You will pass an MenuItemID to the function and it will return the Menu Item Description. This will return a scalar (varchar)
With these 2 functions you will demonstrate that you can create a single SQL Query or Stored Procedure that uses the function call to return the description of all menu items that appear on a given menu. Demonstrate this with a real query.
You will turn in a report that contains; (1) the text of the 2 functions (2) a screen capture of your query, and (3) the results of the query (doc or pdf format - pdf preferred).
NOTE You may substitute tables of your own design and write 2 function that meet the same requirements as these functions. The function must use multiple tables, one must return a table, the other a scalar (varchar or text). Please include design details of your tables if you use this option. If you do this you are expected to also include a discussion (purpose, design) about your database on the discussion boards.
|
Information
First create and test your functions - once complete start thinking about the final requirement - given a menu ID - returning a description of each item on the menu.
Estimated Completion Time
Allot a few hours for this (it took me about 15 minutes to complete)
Supporting Lectures
Week 4 lectures and reference COP4709 Course Lectures By Week
Questions and Answers
External Resources
Grading Criteria
5 Points for each successful stored function.
Comments (0)
You don't have permission to comment on this page.