G-4110: Always use %NOTFOUND instead of NOT %FOUND to check whether a cursor returned data.
Reason
The readability of your code will be higher when you avoid negative sentences.
Example (bad)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | declare
cursor c_employees is
select last_name
,first_name
from employees
where commission_pct is not null;
r_employee c_employees%rowtype;
begin
open c_employees;
<<read_employees>>
loop
fetch c_employees into r_employee;
exit read_employees when not c_employees%found;
end loop read_employees;
close c_employees;
end;
/
|
Example (good)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | declare
cursor c_employees is
select last_name
,first_name
from employees
where commission_pct is not null;
r_employee c_employees%rowtype;
begin
open c_employees;
<<read_employees>>
loop
fetch c_employees into r_employee;
exit read_employees when c_employees%notfound;
end loop read_employees;
close c_employees;
end;
/
|