ORA-01403 no data found
Cause: In a host language program, all records have been fetched. The return code from the fetch was +4, indicating that all records have been returned from the SQL query. Action: Terminate processing for the SELECT statement.

解决方案 »

  1.   

    因为假如你的ID不存在就会抛出no_data_found异常了
    declare 
       n_id number;begin
       
       select r_id into n_id from a;
       //id存在时 
       n_id := r;   exception when no_data_found then
       n_id:=0;
    end;
         
       这样即可得到当前最大的id值了,然后你再根据你的需要去处理就得了
      

  2.   

    select nvl(r_id,0) into n_id from a;
      

  3.   

    建议用SEQUENCE来生成ID,否则多个进程同时调用时可能会重。
    CREATE SEQUENCE TEST_SEQ START WITH 1.....
      

  4.   

    declare 
    declare 
       n_id number;begin
       
       select id+1 into n_id from (select id,rowid from a order by rowid desc) where rownum<2;
       --id存在 时n_id即为当前表中最大的ID值+1;   exception when no_data_found then
       n_id:=1;  --听你的意思好象是得到0后还要再加1吧
       dbms_output.put_line(n_id);
    end;
    上面一个用nvl的,我执行时,当表A为空时,好象还是抛出no_data_found的异常耶
      

  5.   

    嗯,用sequence解决最好,如果想让ID顺序增加,中间不跳号的话,用触发器解决就OK了
      

  6.   

    select nvl(max(id),0) into v_temp from tableB
    v_temp := v_temp+1;
      

  7.   

    Oracle 8I以后用
    begin
    select r_id
    into n_id 
    from a;n_id := r;exception no_data_found then
      n_id := 0;
    end ;
      

  8.   

    select decode(max(r_id),null,0,r) into n_id from a;
      

  9.   

    select Nvl(max(r_id),0) +1 into n_id from a;