Oracle PL/SQL:我的触发器没有';我不能提出例外

Oracle PL/SQL:我的触发器没有';我不能提出例外,oracle,plsql,triggers,Oracle,Plsql,Triggers,我的代码是: 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_s

我的代码是:

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\u application\u error”,它可以工作,但我不知道为什么我不能对异常执行相同的操作。

按照您的方式(在您发布的触发代码中),它实际上“工作”按设计:如果
emp\u ast
表中的
salary
不在
jobs2
表中的
minu salary
max\u salary
之间,对于相同的
job\u id
,trigger在支持它的客户端上显示消息(使用
dbms\u输出。放置行
)(如SQL*Plus或SQL Developer或TOAD;但不在Oracle窗体或Apex中),如果启用

仅此而已。行已成功更新

如果您想引发一个错误,那么是的-您必须实际引发它,就像您之前在
引发应用程序错误时所做的那样


同时,Oracle按你所说的去做:检查某些条件并显示消息。这里没有什么可以防止<代码> Update <代码> .< /P>当你放入一个异常处理程序(Exabl当ExabyTys/<代码>)时,它意味着“不要引发这个异常”。顺便说一下,我建议你考虑一下。