if cursor%found, if cursor%notfound
SQL>
SQL> create table t ( object_id primary key, object_name )
2 organization index
3 as
4 select object_id, object_name from all_objects;
Table created.
SQL>
SQL> create or replace procedure explicit
2 as
3 l_object_name t.object_name%type;
4 l_dummy t.object_name%type;
5
6 cursor c( l_object_id in number ) is select object_name from t where object_id = l_object_id;
7 begin
8 for i in 1 .. 30000
9 loop
10 open c(i);
11 fetch c into l_object_name;
12 if ( c%notfound ) then
13 l_object_name := null;
14 end if;
15 fetch c into l_dummy;
16 if ( c%found ) then
17 raise too_many_rows;
18 end if;
19 close c;
20 end loop;
21 end;
22 /
Procedure created.
SQL>
SQL>
SQL> drop table t;
Table dropped.
Related examples in the same category