Howdy!
It wouldn’t be a GA if I didn’t post SOMETHING about the beta just before release, so…
In Code Analysis, Rule 6405 (avoid unused variables) is popping up for:
Howdy!
It wouldn’t be a GA if I didn’t post SOMETHING about the beta just before release, so…
In Code Analysis, Rule 6405 (avoid unused variables) is popping up for:
…and when I pasted the code, it sent the post instead! Does that count for two posts? ANYWAY, here’s the code in violation (hopefully):
– Exceptions
e_ins_priv EXCEPTION;
v_ins_priv CONSTANT BINARY_INTEGER := -20999;
v_ins_priv_txt CONSTANT VARCHAR2(64) := 'insufficient privileges';
PRAGMA EXCEPTION_INIT(e_ins_priv, -20999);
The exception is on “e_ins_priv” even though it’s used in the EXCEPTION_INIT. This is obviously in a DECLARE block of a PL/SQL procedure.
Thanks!
Rich
This is an auto-responder.
The Toad 12 Beta is now closed. Thank you for your participation. If any problems seem to remain with Toad 12 they were either intended or are user error.
Unless they are in Code Analysis, which is authored by Greg, in which case we aren’t surprised.
Good day!
From: Rich J. [mailto:bounce-rjesse@toadworld.com]
Sent: Wednesday, June 19, 2013 9:28 AM
To: toadoraclebeta@toadworld.com
Subject: [Toad for Oracle - Beta Discussion Forum] Minor issue with Code Analysis rul 6405
Howdy!
It wouldn’t be a GA if I didn’t post SOMETHING about the beta just before release, so…
In Code Analysis, Rule 6405 (avoid unused variables) is popping up for:
This is an auto-responder.
The Toad 12 Beta is now closed. Thank you for your participation. If any problems seem to remain with Toad 12 they were either intended or are user error.
Unless they are in Code Analysis, which is authored by Greg, in which case we aren’t surprised.
Good day!
From: Rich J. [mailto:bounce-rjesse@toadworld.com]
Sent: Wednesday, June 19, 2013 9:31 AM
To: toadoraclebeta@toadworld.com
Subject: RE: [Toad for Oracle - Beta Discussion Forum] Minor issue with Code Analysis rul 6405
…and when I pasted the code, it sent the post instead! Does that count for two posts? ANYWAY, here’s the code in violation (hopefully):
– Exceptions
e_ins_priv EXCEPTION;
v_ins_priv CONSTANT
BINARY_INTEGER
:=
-20999;
v_ins_priv_txt CONSTANT
VARCHAR2(64)
:=
‘insufficient privileges’;
PRAGMA
EXCEPTION_INIT(e_ins_priv,
-20999);
The exception is on “e_ins_priv” even though it’s used in the EXCEPTION_INIT. This is obviously in a DECLARE block of a PL/SQL procedure.
Thanks!
Rich
Hi Rich,
Is the exception being raised on the initial declaration of ‘e_ins_priv’ or the one in the EXCEPTION_INIT call? Do you have an exception in the main body
of your code that uses this variable?
I was not able to replicate this issue with this simple routine. I get a 6405 error on ‘l_test2’, but that’s expected as I didn’t use it in the main body
of the code. I did however use l_exception, so the rule was not fired for this. If I comment out the exception section of the code, then this rule triggers for me, which would be correct.
My guess is maybe this exception was not used in the main pl/sql code, but that’s just a guess. Maybe you can try the simple code below to see if the rule
is triggered.
declare
l_test
integer;
l_test2
integer;
l_exception
exception;
PRAGMA
EXCEPTION_INIT(l_exception,
-20999);
begin
l_test
:=
2;
exception
when l_exception
then
l_test
:=
0;
when
others
then
l_test
:=
1;
end;
From: Rich J. [mailto:bounce-rjesse@toadworld.com]
Sent: Wednesday, June 19, 2013 9:31 AM
To: toadoraclebeta@toadworld.com
Subject: RE: [Toad for Oracle - Beta Discussion Forum] Minor issue with Code Analysis rul 6405
…and when I pasted the code, it sent the post instead! Does that count for two posts? ANYWAY, here’s the code in violation (hopefully):
– Exceptions
e_ins_priv EXCEPTION;
v_ins_priv CONSTANT
BINARY_INTEGER
:=
-20999;
v_ins_priv_txt CONSTANT
VARCHAR2(64)
:=
‘insufficient privileges’;
PRAGMA
EXCEPTION_INIT(e_ins_priv,
-20999);
The exception is on “e_ins_priv” even though it’s used in the EXCEPTION_INIT. This is obviously in a DECLARE block of a PL/SQL procedure.
Thanks!
Rich
Ahhh, the perils of copy-n-pasting code. I understand now. The defined exception isn’t being used in the code, only initialized in the declaration. And in this case, I’m not sure how (or why) one would trap user-defined errors that way…
Issue cheerfully withdrawn.
Thanks Dennis!
Rich
Hi Rich,
I agree with Dennis, the use of the exception in an EXCEPTION_INIT pragma doesn’t count as usage.
Andre
Perhaps seven years old, alltough for clarity the behavior as of the upcoming beta (as of Aug 2, 2020) will be:
The PRAGMA EXCEPTION_INIT clause on an exception does not count as a usage.
Example:
DECLARE
e_ins_priv EXCEPTION; -- hit
PRAGMA EXCEPTION_INIT (e_ins_priv, -20999);
BEGIN
raise e_some_other_exception;
END;