Re: Code Analysis false positives for dead code with case statement
"Jonathan" <[email protected]>
| Newsgroups | gmane.comp.db.oracle.toad.free |
|---|---|
| Message-ID | <[email protected]> |
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
<*> 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/