declare numa varchar2(12); begin select MSNB02 into numa from ds4.tc_msnb_file where MSNB01='1'; end; 当MSNB01查到数据时正常,当查不到数据时,就会报错ORA-01403 找不到资料难道空值不能into给变量吗?
--当查不到数据的时候,会报no_data_found的异常,因此你需要对此类异常进行处理 --捕获异常declare numa varchar2(12); begin select MSNB02 into numa from ds4.tc_msnb_file where MSNB01='1'; --捕获异常 exception when no_data_found then numa:=null; --异常处理 end;
是的,不仅是不能为空,而且结果要是大于1个的话也会报错
--捕获异常declare
numa varchar2(12);
begin
select MSNB02 into numa from ds4.tc_msnb_file where MSNB01='1';
--捕获异常
exception when no_data_found then
numa:=null; --异常处理
end;
可是假如我在这个存储过程中,定义了n个变量,有好几个变量都是select出来的数据,但是也有可能为空,那样异常的话,我就不知道该怎么提示了。
我无法判断哪个为空,就无法进行相应的处理,
可是我用num:= select 会报错
新手,刚接触oracle请问要怎么处理呢?