declare
e_highlimit exception;
v_sal employees.salary%type;
begin
update employees
set salary = salary + 500
where employeeid = 120
returning salary into v_sal;
if v_sal > 8000 then
raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('the salary is too large');
rollback;
end;
e_highlimit exception;
v_sal employees.salary%type;
begin
update employees
set salary = salary + 500
where employeeid = 120
returning salary into v_sal;
if v_sal > 8000 then
raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('the salary is too large');
rollback;
end;
本文介绍了一个使用PLSQL编写的程序,该程序用于更新员工薪资并增加500元,同时通过条件判断检查更新后的薪资是否超过8000元。如果超过,则触发自定义异常,并显示错误信息,同时回滚更改。

被折叠的 条评论
为什么被折叠?



