Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write short programs as requested, the outputs of the program are required to be attached in your submission. Q 1 , ( 1 5 points

Write short programs as requested, the outputs of the program are required to be attached in your submission.
Q1,(15 points) A standalone procedure, based on Employees Table.
In this question, you will create a standalone Procedure called Calc_bonus. This procedure will Get an employee's ID, then calculate the bonus according to the policy below. It should claim one IN parameter (you give it a name), its data type is same as employee_id (number (6)), and one OUT mode parameter (you give it a name), that is the bonus calculated based on the policy.
For employees that their salaries are $10,000 or more, bonus is $2,000.
For employees that their salaries are $7,000 or more but less than $10,000, bonus is $1,600.
For employees that their salaries are $5,000 or more but less than $7,000, bonus is $1,300.
All other employees will get $1,000.
After having successfully compiled the procedure, write an anonymous PL/SQL program. It will call this procedure Calc_bonus for each employee in department 20 and 30. The program will print out each employee's ID, salary, and the bonus.
Also, your program will print out the total bonus for this department 20 and 30.
Q2.(15 points) Write a PL/SQL (block) program, based on Locations and Departments table.
In this question you will define a user-defined record type, then define a nested table data type using this record type as its element. The detailed requirements are as below.
Define a user-defined record type called Dept_Loc has two fields in it:
D_No: correspondent to department_id in the Departments table),
D_Loc: this will be the concatenation of street_address, a comma and a space (||',||), then the city name from the Locations table.
After having defined this record type, your program will declare a nested table data type called Dept_Loc_List that use this record type as its element. You should declare a variable of this nested table data type, you give it a name.
Your program will retrieve the data from Departments and Locations tables for all the departments that have a department manager assigned. Populate this nested table variable with the retrieved data, print out the contents of it: the department ID's and the location strings for each department. Please make the output order by the department ID.
In this question, you are required to use cursor for loop.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions