Написать процедуру удаления job_id из jobs если данный job не используется как в employees так и в job_history
create or replace procedure delete_job (p_job_id varchar)
is
v_count number(3);
r_job exception;
begin
select count(*)
into v_count
from(select employee_id
from employees where job_id = p_job_id
union
select employee_id
from job_history where job_id = p_job_id);
if v_count = 0 then
delete from jobs where job_id = p_job_id;
if sql%notfound then
raise_application_error(-20201, 'Invalid Job Id');
end if;
else
raise r_job;
--raise_application_error(-20200, 'Job cannot be deleted as it has employees');
end if;
exception
when r_job then
raise_application_error(-20200, 'Job cannot be deleted as it has employees');
end;