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