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

2024-11-24 03:33:38
推荐回答(1个)
回答1:

这个不能返回相关错误信息
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 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 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;