Нет такой вещи, как "oracle sql server" (как подсказывает ваш заголовок). Это либо «Oracle», либо «(Microsoft) SQL Server». Код, который вы разместили, - Oracle, поэтому я бы посоветовал вам исправить заголовок.
Теперь ваш вопрос: как count (*) не будет работать, «данные не найдены», ни «sql% notfound»«когда там ничего нет (но 0 в результате) - посмотрите демонстрацию:
SQL> select count(*) from dual where 1 = 2;
COUNT(*)
----------
0
SQL>
тогда вы можете сделать что-то вроде этого:
FOR l in c LOOP
begin
select count(*) into variable
from table where job = 'Manager'
and condition;
if variable = 0 then
RAISE e_my_exception;
end if;
--the code to check salary of employee greater than president or lower than 100 is here //
exception
WHEN e_my_exception THEN
DBMS_OUTPUT.PUT_LINE('ERROR!!! One department has no manager ');
END LOOP;
Такой код будет отображать сообщение(если ваш инструмент его поддерживает), но цикл продолжится зацикливание , т. е. ваш код не остановится.
Хотя, на самом деле, вы не повышаете что-нибудь, более простой вариант будет
FOR l in c LOOP
select count(*) into variable
from table where job = 'Manager'
and condition;
if variable = 0 then
DBMS_OUTPUT.PUT_LINE('ERROR!!! One department has no manager ');
end if;
--the code to check salary of employee greater than president or lower than 100 is here //
END LOOP;