declare
e_highlimit exception;
v_sal employees.salary%type;
begin
select salary
into v_sal
from employees
where lastname = 'smith' update employees set salary = salary + 500
where employeeid = 120
if v_sal > 6000 then raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('the salary is too large');
rollback;
when others then
dbms_output.put_line(sqlcode || ' ' || sqlerrm);
end;
e_highlimit exception;
v_sal employees.salary%type;
begin
select salary
into v_sal
from employees
where lastname = 'smith' update employees set salary = salary + 500
where employeeid = 120
if v_sal > 6000 then raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('the salary is too large');
rollback;
when others then
dbms_output.put_line(sqlcode || ' ' || sqlerrm);
end;
本文介绍了一个使用PL/SQL编写的简单示例程序,该程序用于从数据库中读取员工信息,并根据特定条件更新薪资。如果薪资超过预设阈值,则程序将回滚更改并输出警告消息。
3万+

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



