Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01403: no data found

happy10319May 9 2019 — edited May 10 2019

Hi,

on R12.2 on linux,

The following code stops because a select statement returns no rows.

Effectivly this select (on line 17)returns no row:

select col1 from T where col1=5;

How can bypass it and make it continu?

Here is the code:

DECLARE

n T.col1%type;

n2 T.col1%type;

cursor mycur is

select col1 from T;

BEGIN

OPEN mycur;

LOOP

FETCH mycur into n;

  EXIT WHEN mycur%notfound;

CASE n

when 1 then

select col1 into n2 from T where col1=1;

  dbms\_output.put\_line('N IS : '||n);

select col1 into n2 from T where col1=5;

  dbms\_output.put\_line(' Again N IS : '||n);

when 7 then

select col1 into n2 from T where col1=1;

  dbms\_output.put\_line('N IS :'||n );

else dbms_output.put_line('N IS NOTHING :' );

END CASE;

END LOOP;

CLOSE mycur;

END;

ORA-01403: no data found ORA-06512: at line 17

Thanks.

PS:

create table T (col1 varchar2(10));

insert into T values(1);

insert into T values(2);

insert into T values(3);

pastedImage_0.png

This post has been answered by Mustafa KALAYCI on May 10 2019
Jump to Answer
Comments
Post Details
Added on May 9 2019
11 comments
730 views