Write a Stored Procedure SP_Report_NEW_Budget using the view you created in Part 1-3). Use CURSOR to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Stored Procedure SP_Report_NEW_Budget using the view you created in Part 1-3). Use CURSOR to write the stored Procedure for the tasks below. does the following tasks: Your Stored Procedure SP_Report_NEW_Budget 1) It creates a new table NEW_Dept_Budget as below: NEW_Dept_Budget has 5 columns Dept No (Int) Dept Name (Char(30)) COUNT_Emp (INT) New_SUM_Salary (INT) New_AVE_Salary (INT) 2) Check if the view VDept_Budget is empty or not (by counting rows from the view). 3) If not empty, For each row of the view VDept_Budget, populate (Insert) the new table NEW_Dept_Budget from the view VDept_Budget and New_SUM_Salary, New_AVE_Salary with the newly calculated two columns as calculated below. Calculate New_SUM_Salary, New_AVE_Salary as follow: If Dept = 1, Increase SUM (Salary) by 10% If Dept = 4, Increase SUM (Salary) by 20% If Dept = 5, Increase SUM (Salary) by 30% If Dept = 7, Increase SUM (Salary) by 40% You can also do this task in your stored procedure by populating (insert) the new table directly from the view first then update two columns of the new table with the newly calculated new Sum and new Ave later. Output in screen captures for the Stored Procedure created and the execution of the Stored Procedure by showing the contents of the View and the new table in Select statements in your output. COMPANY DATABASE EMPLOYEE FNAME MINI LNAME T John B Franklin T Joyce A Ramesh K James E Jennifer S Ahmad V Alicia J DEPARTMENT DNAME Headquarters Administration Research Automation PROJECT DEPT LOCATIONS DNUMBER DEPENDENT ESSN 123456789 Alice 123456789 Elizabeth ProductX ProductY ProductZ 123456789 Michael 333445555 Alice 333445555 Joy 333445555 Theodore 987654321 Abner 4 5 PNAME 1 333445555 333445555 333445555 453453453 453453453 5 5 Computerization Reorganization Newbenefits WORKS ON ESSN 123456789 123456789 333445555 666884444 888665555 987654321 987654321 987987987 DNUMBER Smith Wong DEPENDENT_NAME English Narayan Borg Wallace 1 2 2 Jabbar Zelaya DLOCATION Houston Stafford Bellaire Sugarland Houston 3 10 20 1 2 3 20 20 30 10 987987987 30 999887777 10 999887777 30 PNUMBER PNO Hours 32.5 7.5 10 10 1 4 5 333445555 7 123456789 10 10 20 20 40 15 SSN 20 35 123456789 333445555 5 10 30 453453453 666884444 888665555 987654321 987987987 999887777 MGRSSN 888665555 987654321 1 Bellaire 2 Sugarland 3 Houston 10 Stafford 20 Houston 30 Stafford SEX F F M F F M M BDATE 09-Jan-55 08-Dec-45 31-Jul-62 15-Sep-52 10-Nov-27 20-Jun-31 29-Mar-59 19-Jul-58 MGRSTARTDATE 19-Jun-71 01-Jan-85 22-May-78 06-Oct-05 PLOCATION DNUM 5 5 BDATE 31-Dec-78 Daughter 05-May-57 Spouse 01-Jan-78 Son 05-Apr-76 Daughter 03-May-48 Spouse 25-Oct-73 Son 29-Feb-32 Spouse 5 4 I 4 ADDRESS 731 Fondren, Houston, TX 638 Voss, Houston, TX 5631 Rice, Houston, TX 975 Fire Oak, Humble, TX 450 Stone, Houston, TX 291 Berry, Bellaire, TX 980 Dallas, Houston, TX 3321 Castle, SPring, TX RELATIONSHIP SEX M M F M M F M F SALARY 30000 40000 25000 38000 55000 43000 25000 25000 SUPERSSN DNO 987654321 888665555 333445555 333445555 5 5 5 5 1 4 4 4 888665555 987654321 987654321 Write a Stored Procedure SP_Report_NEW_Budget using the view you created in Part 1-3). Use CURSOR to write the stored Procedure for the tasks below. does the following tasks: Your Stored Procedure SP_Report_NEW_Budget 1) It creates a new table NEW_Dept_Budget as below: NEW_Dept_Budget has 5 columns Dept No (Int) Dept Name (Char(30)) COUNT_Emp (INT) New_SUM_Salary (INT) New_AVE_Salary (INT) 2) Check if the view VDept_Budget is empty or not (by counting rows from the view). 3) If not empty, For each row of the view VDept_Budget, populate (Insert) the new table NEW_Dept_Budget from the view VDept_Budget and New_SUM_Salary, New_AVE_Salary with the newly calculated two columns as calculated below. Calculate New_SUM_Salary, New_AVE_Salary as follow: If Dept = 1, Increase SUM (Salary) by 10% If Dept = 4, Increase SUM (Salary) by 20% If Dept = 5, Increase SUM (Salary) by 30% If Dept = 7, Increase SUM (Salary) by 40% You can also do this task in your stored procedure by populating (insert) the new table directly from the view first then update two columns of the new table with the newly calculated new Sum and new Ave later. Output in screen captures for the Stored Procedure created and the execution of the Stored Procedure by showing the contents of the View and the new table in Select statements in your output. COMPANY DATABASE EMPLOYEE FNAME MINI LNAME T John B Franklin T Joyce A Ramesh K James E Jennifer S Ahmad V Alicia J DEPARTMENT DNAME Headquarters Administration Research Automation PROJECT DEPT LOCATIONS DNUMBER DEPENDENT ESSN 123456789 Alice 123456789 Elizabeth ProductX ProductY ProductZ 123456789 Michael 333445555 Alice 333445555 Joy 333445555 Theodore 987654321 Abner 4 5 PNAME 1 333445555 333445555 333445555 453453453 453453453 5 5 Computerization Reorganization Newbenefits WORKS ON ESSN 123456789 123456789 333445555 666884444 888665555 987654321 987654321 987987987 DNUMBER Smith Wong DEPENDENT_NAME English Narayan Borg Wallace 1 2 2 Jabbar Zelaya DLOCATION Houston Stafford Bellaire Sugarland Houston 3 10 20 1 2 3 20 20 30 10 987987987 30 999887777 10 999887777 30 PNUMBER PNO Hours 32.5 7.5 10 10 1 4 5 333445555 7 123456789 10 10 20 20 40 15 SSN 20 35 123456789 333445555 5 10 30 453453453 666884444 888665555 987654321 987987987 999887777 MGRSSN 888665555 987654321 1 Bellaire 2 Sugarland 3 Houston 10 Stafford 20 Houston 30 Stafford SEX F F M F F M M BDATE 09-Jan-55 08-Dec-45 31-Jul-62 15-Sep-52 10-Nov-27 20-Jun-31 29-Mar-59 19-Jul-58 MGRSTARTDATE 19-Jun-71 01-Jan-85 22-May-78 06-Oct-05 PLOCATION DNUM 5 5 BDATE 31-Dec-78 Daughter 05-May-57 Spouse 01-Jan-78 Son 05-Apr-76 Daughter 03-May-48 Spouse 25-Oct-73 Son 29-Feb-32 Spouse 5 4 I 4 ADDRESS 731 Fondren, Houston, TX 638 Voss, Houston, TX 5631 Rice, Houston, TX 975 Fire Oak, Humble, TX 450 Stone, Houston, TX 291 Berry, Bellaire, TX 980 Dallas, Houston, TX 3321 Castle, SPring, TX RELATIONSHIP SEX M M F M M F M F SALARY 30000 40000 25000 38000 55000 43000 25000 25000 SUPERSSN DNO 987654321 888665555 333445555 333445555 5 5 5 5 1 4 4 4 888665555 987654321 987654321
Expert Answer:
Answer rating: 100% (QA)
I see youve provided two images The first image outlines the task of creating a stored procedure nam... View the full answer
Related Book For
Concepts of Database Management
ISBN: 978-111182591
7th edition
Authors: Philip J. Pratt, Joseph J. Adamski
Posted Date:
Students also viewed these databases questions
-
Prepare journal entries to record the following transactions. Purchased land for $81,800 and a building for $321,800. The purchase is paid for with $61,800 cash and a note payable for $341,800. Paid...
-
1. Create a view named LargeSlip using the data in the MarinaNum, SlipNum, RentalFee, BoatName, and OwnerNum columns in the MarinaSlip table for those slips with lengths of 40 feet. Display the data...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Suppose that two stocks whose rates of return are given by the two-factor arbitrage pricing model r= a +31 +42 r2 = 02 +241 +2, where a, and a2 are constants. Furthermore, there is a risk-free asset...
-
Design a synthesis of m-bromophenol from benzene.
-
The after-closing trial balance of the Lin, Mae, and Nel partnership at December 31, 2011, was as follows: ADDITIONAL INFORMATION 1. The partnership is to be liquidated as soon as the assets can be...
-
A survey of 339 college and university admissions directors and enrollment officers found that 72% think their institution is losing potential applicants due to concerns about accumulating student...
-
Saira Morrow operates Dressage Riding Academy, Inc. The academy's primary sources of revenue are riding fees and lesson fees, which are provided on a cash basis. Saira also boards horses for owners,...
-
Houston stock is selling for $47 and has the following six-month options outstanding. Strike Price Option Market Price Call Option $45 $5 Call option $50 $2 a. Which option(s) is (are) in the...
-
CSC20 Project 4 For this project our aim is to create a phone book with contact details. Individual contact information is added to the contact class. Then these contacts are added to the Phone books...
-
a. Using hindsight (which is 20/20, of course!), list and discuss some of the specific fraud factors at DHB that should have served as red flags to the auditors. b. What could (should?) the auditors...
-
In what ways do theories of cognitive dissonance, as formulated by Leon Festinger, contribute to our understanding of the psychological discomfort individuals experience when confronted with...
-
1. Management activities are divided into four functions, which are: Planning, Organizing, Directing and Coordinating Controlling. You are employed as the manager of XYZ FBO, with approximately ten...
-
What did VW do well, and not-so-well in managing their crisis? Reflect on the five practical steps in Chapter 6 on "Managing Business Crises" and identify the areas where, according to the expert in...
-
For simplicity, we hold the price level fixed at 1 and assume that inflationary expectations are fixed at 2%. Initial Conditions before the fall of 2008 mm = money multiplier = 1.6 MB = monetary base...
-
Business Law - United States Principle vs Agent, the concept of representation. What are some past legal cases (atleast 3) and law sections that outline and specify the duty of obedience as an agent?...
-
An analyst has estimated how a particular stock's return will vary depending on what will happen to the economy. What is the expected rate of return? 1. STATE OF THE ECONOMY Recession Below Average...
-
Saccharin is an artificial sweetener that is used in diet beverages. In order for it to be metabolized by the body, it must pass into cells. Below are shown the two forms of saccharin. Saccharin has...
-
1. The DBA asks for your help in planning the data archive for the following Henry Books database: Branch (BranchNum, BranchName, BranchLocation) Publisher (PublisherCode, PublisherName, City) Author...
-
What is a computed field? How can you use one in an SQL query? How do you assign a name to a computed field?
-
What is location transparency?
-
Consider the multiple linear regression model fit to the baseball data in Problem 3.41. Problem 3.41 Consider the 2016 major league baseball data in Table B.22. While team ERA was useful in...
-
Consider the simple linear regression model fit to the rental price data from Problem 2.36. Data From Problem 2.36 Table B.24 contains data on median family home rental price and other data for 51 US...
-
Consider the multiple linear regression model fit to the rental price data in Problem 3.42. Problem 3.42 Table B.24 contains data on median family home rental price and other data for 51 US cities....
Study smarter with the SolutionInn App