PL/SQL Control Statement Exercises: Count the number of employees in a specific department and check whether this department have any vacancies or not. If any vacancies, how many vacancies are in that department
PL/SQL Control Statement: Exercise-9 with Solution
Write a PL/SQL program to count the number of employees in a specific department and check whether this department have any vacancies or not. If any vacancies, how many vacancies are in that department.
Sample Solution:
Table: employees
employee_id integer first_name varchar(25) last_name varchar(25) email archar(25) phone_number varchar(15) hire_date date job_id varchar(25) salary integer commission_pct decimal(5,2) manager_id integer department_id integer
Table: departments
department_id integer department_name varchar(25) manager_id integer location_id integer
PL/SQL Code:
Sample Output:
Enter value for new_dep_id: 20 old 6: get_dep_id := '&new_dep_id'; new 6: get_dep_id := '20'; The employees are in the department 20 is: 2 There are 43 vacancies in department 20 PL/SQL procedure successfully completed.
Flowchart:

Improve this sample solution and post your code through Disqus
Previous: Write a PL/SQL program to display the description against a grade.
Next: Write a PL/SQL program to display the description against a grade using CASE statement.
What is the difficulty level of this exercise?
Based on 136 votes, average difficulty level of this exercise is Medium
.