RE: Re: Code Analysis false positives for dead code with case statement

Bert Scalzo <[email protected]>
Newsgroups gmane.comp.db.oracle.toad.free
Message-ID <228D4BD15697E04CAF6CD482362F2ACE1041B759@ALVMBXW01.prod.quest.corp>
You can simply customize your rule set to remove this rule until it's fixed - so there is a workaround ....

From: [email protected] [mailto:[email protected]] On Behalf Of Jonathan
Sent: Friday, June 22, 2012 8:07 AM
To: [email protected]
Subject: [toad] Re: Code Analysis false positives for dead code with case statement



Any idea when these might be fixed?

I'd like to start using this tool to scan our code before it goes onto production to pick up simple errors such as these but if we get too many false positives from it will lose any credibilty with the developers who won't want to spend any time working out if it is a valid fail or not.

--- In [email protected]<mailto:toad%40yahoogroups.com>, Gregory Liss <gregory.liss@...<mailto:gregory.liss@...>> wrote:
>
> You found another legacy rule. :(
>
> -----Original Message-----
> From: [email protected]<mailto:toad%40yahoogroups.com> [mailto:[email protected]<mailto:toad%40yahoogroups.com>] On Behalf Of Jonathan
> Sent: Friday, June 22, 2012 08:33 AM
> To: [email protected]<mailto:toad%40yahoogroups.com>
> Subject: [toad] Re: Code Analysis false positives for dead code with case statement
>
> I think I've found another issue this time with rule 2601: Ensure locally opened cursors will be closed.
>
> I believe that in this code snippet it is incorrect in saying the rule fails (I've built this example using the structure of some production code we have) because as far as I can tell the cursor will be closed either at the end of the loop or if the exception is raised.
>
> CREATE OR REPLACE PROCEDURE testproc (x IN PLS_INTEGER) AS
> CURSOR testcur
> IS
> SELECT * FROM DUAL;
>
> testrec testcur%ROWTYPE;
>
> testexception EXCEPTION;
> BEGIN
> OPEN testcur;
>
> LOOP
> FETCH app_cur INTO app_rec;
>
> EXIT WHEN app_cur%NOTFOUND;
>
> IF x = 1
> THEN
> BEGIN
> --Some code
> NULL;
> EXCEPTION
> WHEN OTHERS
> THEN
> RAISE testexception;
> END;
> ELSE
> BEGIN
> --Some code
> NULL;
> EXCEPTION
> WHEN OTHERS
> THEN
> RAISE testexception;
> END;
> END IF;
> END LOOP;
>
> CLOSE testcur;
> EXCEPTION
> WHEN testexception
> THEN
> CLOSE testcur;
> END;
>
> Am I correct that this code is okay and shouldn't be failing this rule?
>
> Regards,
>
> Jonathan
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.