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've been looking at using the Code analysis tool to find dead code in our pl/sql packages but we seem to get a number of false positives where we have a case statements like this :
CREATE OR REPLACE FUNCTION testfunc (p_task_id IN NUMBER)
RETURN VARCHAR2
IS
l_return VARCHAR2 (100);
BEGIN
CASE (p_task_id)
WHEN 1
THEN
l_return := 'active';
ELSE
l_return := 'inactive';
END CASE;
RETURN l_return;
END testfunc;
If you do the code analysis on this function it will say it fails on Rule 6801: Ensure all statements can be reached (dead code). - [Code Correctness, PLSQL, Information] (11: 22).
But the code works correctly, if you call select testfunc(1) from dual; it returns 'active' any other value returns 'inactive'.
Now if you remove the parenthesis from the case statement so it reads :
CASE p_task_id
then it passes the rule, but surely the parenthesis are allowed as part of the case statement as it compiles and executes correctly.
Is the rule faulty or should we not be using the parenthesis in our code?
Thanks,
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/