create or replace procedure pout(i number,o out varchar2) is begin select ename into o from my where empno=i; --if sql%notfound then --dbms_output.put_line('wrong'); --else dbms_output.put_line(o); --end if; exception when no_data_found then dbms_output.put_line('wrong'); end;
begin
select ename into o from my where empno=i;
--if sql%notfound then
--dbms_output.put_line('wrong');
--else
dbms_output.put_line(o);
--end if;
exception
when no_data_found then
dbms_output.put_line('wrong');
end;
一般在使用SQL%ROWCOUNT时主要用于判断update、delete等更新、删除了多少记录
而在select时,由于选择不到数据,也就无法进行into了,从而产生异常,所以只能用exception来捕捉异常了。