Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 4 . ( 1 5 points ) Note that Q 5 and Q 6 are based on this question Q 4 . Write a

Q4.(15 points) Note that Q5 and Q6 are based on this question Q4.
Write a PL/SQL block, in that program, define a local procedure named Dept_Head_name. This procedure lives in that block only, it is also called nested procedure.
This procedure will have one IN parameter called Deptno and one OUT parameter called head_name. It accepts the Department_ID as IN parameter, and its OUT parameter will pass back the full name of manager who is the head (manager) of that department to the invoking program.
In the executable section, the program will invoke this procedure Dept_Head_name with the department ID of 60 as IN parameter value. The program will print out the department ID and the full name of its manager.
You have the experience with this kind query before. When use this query in PL/SQL block, you need to change the literal value 60 into a variable name.Q5.(10 points)This question 5 is based on question 4. This time, you will change the local procedure in Q4 into a standalone procedure. Your program will consist of two parts. The first part is a program of "create or replace procedure" that will create a standalone procedure called Dept_Head_name. Same structure as in Q4. You should finish the compilation of this "create procedure" code before you invoke that procedure.
After having successfully compiled the stand alone procedure, you will write a separate PL/SQL block, in its executable section, the program will invoke this procedure passing the value of 60 of department ID to the procedure, your program will store the OUT parameter value into your local variable. Your program will then print out the result.
Simply say, change the code in q4, make the procedure as a stand alone via create or replace it in the DB schema level. Then you may call it in your PL/SQL block.
Q6.(15 points) Based on question 5.
This time, you will print out the managers' full names for all the departments that have assigned manager.
Assuming that you have created the procedure in Q5, so you do not need to repeat your "create procedure" code, just write one PL/SQL that will invoke standalone procedure.
In the PL/SQL block, you will define a cursor that will return all the department ID's
(... from departments where manager_id is not null), run a loop, repeatedly invoke that procedure. Your program needs to provide the value of department_id you get from cursor to the procedure, and assign the OUT parameter value from the procedure into your local variable. Then print out the info.
Please try to find out all the 3 questions
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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions