declare v_ename varchar2(5);
begin
select ename into v_ename from emp
where empno=&no;
dbms_output.put_line('雇员名:'||v_ename);
exception
when no_data_found then
dbms_output.put_line('请输入正确的雇员号!');
end;
在存储过程中,select name into v_name from table where 条件的时候,如果没有查到数据,
就不能将V_name进行赋值,就会抛出no_data_found异常,程序不能继续执行
begin
select ename into v_ename from emp
where empno=&no;
dbms_output.put_line('雇员名:'||v_ename);
exception
when no_data_found then
dbms_output.put_line('请输入正确的雇员号!');
end;
在存储过程中,select name into v_name from table where 条件的时候,如果没有查到数据,
就不能将V_name进行赋值,就会抛出no_data_found异常,程序不能继续执行
本文介绍了一个Oracle PL/SQL存储过程示例,演示了如何使用no_data_found异常来处理查询未返回数据的情况,并展示了如何通过输出语句来提示用户输入正确的雇员编号。
712

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



