Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G-5060 bug with 2 queries #47

Open
nbroucke opened this issue Aug 29, 2024 · 1 comment
Open

G-5060 bug with 2 queries #47

nbroucke opened this issue Aug 29, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@nbroucke
Copy link

nbroucke commented Aug 29, 2024

We get a violation G-5060 : Avoid unhandled exceptions
with this code (just showing part of the code) :

image

when we comment the IF statement the violation is no longer there :

image

@PhilippSalvisberg
Copy link
Collaborator

@nbroucke thanks for reporting this issue.

I can reproduce it with the following code

create or replace package body department_api is
   function name_by_id(in_id in departments.department_id%type)
      return departments.department_name%type is
      co_id             constant departments.department_id%type := in_id;
      l_department_name departments.department_name%type;
   begin
      if true then
         select department_name
           into l_department_name
           from departments
          where department_id = co_id;

         select department_name
           into l_department_name
           from departments
          where department_id = co_id;
      end if;
      return l_department_name;

   exception
      when no_data_found then
         return null;
      when too_many_rows then
         raise;
   end name_by_id;
end department_api;
/

It's related to the if statement. Without the if no G-5060 is reported.

@PhilippSalvisberg PhilippSalvisberg added the bug Something isn't working label Aug 29, 2024
@PhilippSalvisberg PhilippSalvisberg transferred this issue from Trivadis/plsql-cop-sqldev Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants