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]> |
ok, thanks for the quick reply. --- In [email protected], Gregory Liss <gregory.liss@...> wrote: > > Jonathan, > Unfortunately, that's one of the "legacy" rules that we haven't yet converted to the newer XPath technology. We're in the process of converting all rules over to the new technology but you stumbled upon one that isn't quite there yet. > > Greg > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf Of Jonathan > Sent: Thursday, June 21, 2012 11:29 AM > To: [email protected] > Subject: [toad] Code Analysis false positives for dead code with case statement > > 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 > ------------------------------------ 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/