declare
v_name emp.ename%type;
v_sal emp.sal%type:=&salary;
begin
select ename,sal into v_name,v_sal from emp where sal=v_sal;
dbms_output.put_line(v_name||'工资是:'||v_sal);
exception
when no_data_found then
dbms_output.put_line('没有该工资的员工!');
when too_many_rows then
dbms_output.put_line('多个员工具有该工资!');
when others then
dbms_output.put_line('其他异常!');
end;
-- 7369 800 一个员工
-- 7521 7654 1250 多个员工
-- 没有 8000 没有员工
select * from emp;
Oracle 预定义异常
最新推荐文章于 2021-08-09 12:42:02 发布