Write a PL/SQL program to count the number of employees in department 50 and check whether this department have any vacancies or not. There are 45 vacancies in this department

  • pl/sql

Write a PL/SQL program to count the number of employees in department 50 and check whether this department have any vacancies or not. There are 45 vacancies in this department.

الأجوبة

SET SERVEROUTPUT ON
DECLARE
    tot_emp NUMBER;
BEGIN
    SELECT Count(*)
    INTO   tot_emp
    FROM   employees e
           join departments d
             ON e.department_id = d.department_id
    WHERE  e.department_id = 50;

    dbms_output.Put_line ('The employees are in the department 50: '
                          ||To_char(tot_emp));

    IF tot_emp >= 45 THEN
      dbms_output.Put_line ('There are no vacancies in the department 50.');
    ELSE
      dbms_output.Put_line ('There are some vacancies in department 50.');
    END IF;
END; 
/

Sample Output:

The employees are in the department 50: 45
There are no vacancies in the department 50.

PL/SQL procedure successfully completed.
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...