【发布时间】:2020-12-16 04:40:42
【问题描述】:
我的代码是:
create or replace trigger trig6
before update of min_salary, max_salary on jobs2
for each row
declare
exceptie exception;
cursor c is select salary
from emp_ast
where job_id=:new.job_id;
begin
for i in c loop
if i.salary not between :new.min_salary and :new.max_salary then
raise exceptie;
end if;
end loop;
exception
when exceptie then
dbms_output.put_line('Salariile angajatilor nu se afla intre limitele salariului minim si maxim');
end;
/
update jobs2
set max_salary=1000
where job_id='SA_REP';
/
触发器编译成功,但没有引发任何异常。我尝试使用 'raise_application_error' 并且它有效,但我不知道为什么我不能对异常做同样的事情。
【问题讨论】:
-
当您放入异常处理程序 (
exception when exceptie then) 时,它的意思是“不要引发此异常”。 -
对了,我建议你考虑indenting your code。