若的确返回结果为null,这样写是可以的啊。就怕是本身select语句返回的是no_data_found,这样写就不对了。

解决方案 »

  1.   

    请问如果是 no_data_found 的时候应该怎样写呢?
    谢谢~~
      

  2.   

    判断返回的结果为空就这样写
    if  maindcid is null  then
    但没找到就不行了
      

  3.   

    如果是 no_data_found 的时候:
    用异常处理判断
      

  4.   

    如果是 no_data_found
    begin
    select dc_id into maindcid  from main_information where ain_information.dc_id=dcid;
    exception
     when NO_DATA_FOUND then
     ......
    end;
      

  5.   

    select count(*),max(dc_id) into l_count, maindcid  from main_information where ain_information.dc_id=dcid;if l_count > 0 then 
       
    else -- 返回为空的处理
    end if;这样就不必进入异常处理,而是可以继续了。
      

  6.   

    declare
    maindcid main_information.dc_id%type;
    begin
    select dc_id into maindcid  from main_information where ain_information.dc_id=dcid;
    exception
      when no_data_found then 
        --anything;
    end;
    /
      

  7.   

    我的方法试了吗?l_count是需要声明的一个变量l_count number;
      

  8.   

    就是说,在存储过程中能不能用
    exception
      when no_data_found then 
        --anything;
    end;这种异常判定方式
      

  9.   

    Lastdrop(空杯) 你的办法OK OKOK!