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.
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.
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值了,然后你再根据你的需要去处理就得了
CREATE SEQUENCE TEST_SEQ START WITH 1.....
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的异常耶
v_temp := v_temp+1;
begin
select r_id
into n_id
from a;n_id := r;exception no_data_found then
n_id := 0;
end ;