最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

ORA-01403:nodatafoundexception的解决小道

来源:动视网 责编:小采 时间:2020-11-09 11:04:45
文档

ORA-01403:nodatafoundexception的解决小道

ORA-01403:nodatafoundexception的解决小道:问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次使用显式游标, 问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次
推荐度:
导读ORA-01403:nodatafoundexception的解决小道:问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次使用显式游标, 问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次


问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次使用显式游标,

问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次使用显式游标,再打开取值就显得很麻烦。一个经验丰富的老师提出可以用类似max min等这样的聚合函数,,来避免select into带来的异常,又避免每次使用游标的麻烦。

效率和可行性测试:

①临时表

CREATE TABLE EDU.TEST
(
ID NUMBER NULL
)
TABLESPACE EDUCATION
NOLOGGING
PCTFREE 10
PCTUSED 0
INITRANS 1
MAXTRANS 255
STORAGE(BUFFER_POOL DEFAULT)
NOPARALLEL
NOCACHE


② 用PL/SQL块测试

A、create or replace procedure proc_max(id varchar2)
as
var dba_tables.table_name%type:=null;
v_err_code number(10);
v_err_txt varchar2(400);
begin
select max(d.table_name)
into var
from dba_tables d
where d.OWNER='JF'
and d.TABLE_NAME='ORGCONNECTION1012'||id;
if var is not null
then
insert into test values(id);
commit;
end if;
exception
when others then
v_err_code:=sqlcode;
v_err_txt:='测试:'||sqlerrm||DBMS_UTILITY.format_error_backtrace();
insert into proc_err_logs(code,message,info,occur_date)
values(v_err_code,v_err_txt,'EXCEPTION',SYSDATE);
commit;
end;

/
create or replace procedure proc_cur(id varchar2)
as
var dba_tables.table_name%type:=null;
v_err_code number(10);
v_err_txt varchar2(400);
type cursor_type is ref cursor;
cur cursor_type;
begin
open cur for
select d.table_name
from dba_tables d
where d.OWNER='JF'
and d.TABLE_NAME='ORGCONNECTION1012'||id;

fetch cur into var;
close cur;

if var is not null then
insert into test
values(id);
commit;
end if;
exception
when others then
v_err_code:=sqlcode;
v_err_txt:='测试:'||sqlerrm||DBMS_UTILITY.format_error_backtrace();
insert into proc_err_logs(code,message,info,occur_date)
values(v_err_code,v_err_txt,'EXCEPTION',SYSDATE);
commit;
end;

B、

create or replace procedure proc_test_max(var in number)
as
v_err_code number(10);
v_err_txt varchar2(400);
v_begin_time timestamp;
v_end_time timestamp;

begin
select current_timestamp into v_begin_time from dual;

for i in 1..var loop
proc_max(i);
end loop;
select current_timestamp into v_end_time from dual;

insert into proc_use_times(PROC_NAME,
PROC_DESC,
BEGIN_TIME,
END_TIME)
values('proc_test_max','测试'||var,v_begin_time,v_end_time);
commit;
exception
when others then
v_err_code:=sqlcode;
v_err_txt:='测试max:'||var||sqlerrm||DBMS_UTILITY.format_error_backtrace();
insert into proc_err_logs(code,message,info,occur_date)
values(v_err_code,v_err_txt,'EXCEPTION',SYSDATE);
end;

文档

ORA-01403:nodatafoundexception的解决小道

ORA-01403:nodatafoundexception的解决小道:问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次使用显式游标, 问题:在使用select into from tablename这样的隐式游标的时候,如果查不到数据,那么会报ora-01403的错误。而每次
推荐度:
标签: 处理 解决 no
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top