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

Gregory Liss <[email protected]>
Newsgroups gmane.comp.db.oracle.toad.free
Message-ID <C90E462F0168DA46BCC2DC6AD9059A5410D81530@ALVMBXW01.prod.quest.corp>
You found another legacy rule.  :(

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jonathan
Sent: Friday, June 22, 2012 08:33 AM
To: [email protected]
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





------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/toad/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/toad/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
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.