Skip to content

G-4350 is wrongly reported in a cursor FOR loop with a SQL statement #10

@deboiph

Description

@deboiph

Rule G-4350 (Always use 1 as lower and COUNT() as upper bound when looping through a dense array) is wrongly reported in the following code:

begin
FOR r_obj IN (
SELECT obj.object_type, obj.object_name, count(dep.name) cnt
FROM user_objects obj
LEFT JOIN user_dependencies dep
ON dep.type = obj.object_type
AND dep.name = obj.object_name
WHERE obj.object_type in ('TYPE', 'TYPE BODY')
GROUP BY obj.object_TYPE, obj.object_NAME
ORDER BY cnt
)
LOOP
NULL;
END LOOP;
end test;

No array is explicitly used in that code. The issue seems to be linked to this specific SQL query. It disappears when the query is simplified (e.g. SELECT table_name FROM user_tables).

The code to reproduce the problem can be find in the attached file.

deboiph.zip

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions