在sqlplus下执行
select schema1.table1.field2 from schema1.table1 
     where schema1.table.field1 = 'aaa';
能不能检索出数据?

解决方案 »

  1.   

    因为select语句没有找到任何纪录,抛出了一个no_data_found的异常。先确认你的select语句能返回一条记录(也不能返回超过一条记录)。
      

  2.   

    因为select语句没有找到任何纪录,抛出了一个no_data_found的异常。先确认你的select语句能返回一条记录(也不能返回超过一条记录)。
      

  3.   

    ORA-01403: no data found
    means no record has been returned from your SQL query.execute 
    select * from schema1.table1 where schema1.table.field1 = 'aaa';
    to see if there is any record.
      

  4.   

    实在不行,就加个例外处理。
    Exception
    when no_data_found then
    return;
    试试吧
      

  5.   

    i can not assure that the query "select ..." can return any record ,
    one or none or any.What can i do?用英文说明这件破事真费劲,用中文吧:我不能保证这个select语句肯定可以返回一条记录,是否必须使用
    EXCEPTION 
    when no_data_found then
    ...去处理?可不敢直接返回,查不到我还有别的事要做呢。
      

  6.   

    bzszp(SongZip):
    有时能,有时不能,有时会查出好多。(见鬼,赫赫)除了上面的问题,另一个小问题是,如果查出很多,我只想取其中某一个,比如第一个,怎么办?
      

  7.   

    select schema1.table1.field2 into var_temp from (select rownum id,field2 from schema1.table1 where schema1.table.field1 = 'aaa' order by field2) //按照field2排序
         where id=1;
      

  8.   

    用子块来处理吧
    begin
       其它语句;
       begin     //子块开始
         select schema1.table1.field2 into var_temp from (select * from schema1.table1 where schema1.table.field1 = 'aaa' and rownum=1);
       exception
       when no_data_found then
       ....
       when others then
       .... 
       end;     //子块结束
       其它语句;
    end;