Toad World® Forums

Code Analysis: Unused variable not detected


I don’t really know what happens here, hope you can reproduce it.

Paste this code into a new editor tab:

TYPE number_tab IS TABLE OF NUMBER(12);
unused_variable PLS_INTEGER;
IF ( 1 MEMBER OF NEW number_tab() ) THEN
END test_proc;

  1. The unused variable is not detected.

  2. Interesting add-on:

Now compile the procedure and change something in the code to trigger Code Analysis.
Rule 2131 (Use CONSTANT keyword wherever possible) appears.


A few rules still use old legacy code which will not process post 9i code. Rule 6405 (Avoid defining variables that are not referenced inside the program) is one of them. If you change 1 MEMBER OF NEW number_tab() by just 1 then the 6405 will pop up. This is in the pipeline but on longer term.

About 2131 this rule currently also fires whenever the variable (constant) is not referred to at all, it fires when no assignments are found without looking that the var is referenced. This needs fixing. (QP-1875)



Thanks for your answer!

I totally understand the part about legacy code, but I am not sure what you mean by “change by just 1”?

That 2131 shows for unused variables is a minor issue, but I’m really curious why it does not show unless I compile the unit and change something afterwards?

This does not seem to be related to the other issue. When I paste the following code, the warning is only displayed after compiling the unit. Once it has been compiled, warnings are displayed immediately when another unused/constant variable is introduced:

my_constant PLS_INTEGER;
my_variable PLS_INTEGER;
my_variable := my_constant;
END test_proc;


Sorry, I meant

IF ( 1 ) THEN

which does not compile, actually meaning

IF ( true ) THEN


About the 2131 issue, I recompiled and then added a space next to another space, it does not show up here. What did you actually do? Does it appear near the unused_variable declaration?


It looks like this after pasting:


After first time compiling (tab header has changed):


After appending a space (warnings are displayed):



I am lost!! I am using Toad for Oracle and I am unable to get it to recognize variables that are not used. Is there a resolution to this?


Hi Kevin,

We had found an issue in our parser when processing certain specific rules. While Rule 6405 isn’t included in the list of problematic rules, the issue sometimes prevented the completion of the Code Analysis scan process. We temporarily disabled the problematic rules for builds that were released earlier this week until the underlying issue can be fixed. Can you try updating to the latest beta build and see if that solves your problem?

Let us know if you continue to experience problems with it.




Hi Kevin,

I just realized you mentioned, and since this was posted in the Beta forum, I had read that as which was released last week. I can reproduce your issue in Toad 13.0 and Toad 13.1. This issue was fixed in Toad Beta; however in order to use the Beta product, you’ll need to first upgrade your GA version of Toad to the current version, which is