……具体问题如下:编写一个PL/SQL块,修改员工号为201的员工工资为8000 元。跪求答案~谢谢~

编写一个PL/SQL块,修改员工号为201的员工工资为8000

元,保证修改后的工资在职位允许的工资范围之内,否则取消

操作,并说明原因。

第1个回答  推荐于2017-12-16
这个不能返回相关错误信息
declare
v_maxsal employees.salary%type;
v_minsal employees.salary%type;
v_sal employees.salary%type;
e_highlimit exception;
begin
select max(salary) into v_maxsal from employees;
select min(salary) into v_minsal from employees;
select salary into v_sal from employees where employee_id=201;
update employees set salary=salary+8000 where employee_id=201;
if v_sal>v_maxsal then raise e_highlimit;
elsif v_sal<v_minsal then raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('The salary is too large or too little');
rollback;
when others then
dbms_output.put_line('There is some wrong in selecting!');
end;
这个可以返回相关的错误信息
declare
v_maxsal employees.salary%type;
v_minsal employees.salary%type;
v_sal employees.salary%type;
e_highlimit exception;
v_code number(6);
v_text varchar2(200);
begin
select max(salary) into v_maxsal from employees;
select min(salary) into v_minsal from employees;
select salary into v_sal from employees where employee_id=201;
update employees set salary=salary+8000 where employee_id=201;
if v_sal>v_maxsal then raise e_highlimit;
elsif v_sal<v_minsal then raise e_highlimit;
end if;
exception
when e_highlimit then
dbms_output.put_line('The salary is too large or too little');
rollback;
when others then
v_code:=SQLCODE;
v_text:=SQLERRm;
dbms_output.put_line(v_code||''||v_text);
end;本回答被提问者采纳
相似回答