Hi all,
code analysis rule 6702 grumbles when pipelined functions don't have a RETURN statement. Pipelined functions never have a RETURN statement, so the rule doesn't fit for them.
Best regards
Rainer
Hi all,
code analysis rule 6702 grumbles when pipelined functions don't have a RETURN statement. Pipelined functions never have a RETURN statement, so the rule doesn't fit for them.
Best regards
Rainer
Good catch, thank you! Will be fixed. (QP-4075)
FYI, I have a colleague who says that it's still best practice to have an "empty" RETURN in PFs, but you're right, it's not required and Code Analysis should accommodate... thank you Quest Dev!
Gary you say something! Steven Feuerstein in https://blogs.oracle.com/connect/post/pipelined-table-functions also uses empty RETURNs.
I guess the reason is that RETURN inside a function has become part of many developer's DNA.
But Rainer may have meant that the RETURN here is not mandatory and that is true, so the rule should not grumble.
Agreed... not mandatory/required, so our Code Analysis shouldn't "grumble" at valid syntax ...
The fix is fairly simple. If you want to test it yourself then create a rule in user space (#7000-9999) with the following expression:
for $f in //FUNCTION_BODY[not(PIPELINED)]
(::: Find non-pipelined functions which don't have at least one RETURN statement :::)
return
$f[not(.//RETURN/ancestor::FUNCTION_BODY[1][@offset = $f/@offset])] (::: RETURN must not belong to
a nested function body :::)
(::: Mark the last "END" in the function :::)
/STMT/BLOCK/TOKEN[@value = "end"][last()]
Otherwise expect it in Toad beta in a few weeks.
You guys at Quest are so quick and cool...
I don't plan to create a user defined rule, but I look forward to the fix in one of the next releases (usually I don't use betas). The fix has no hurry.
In fact I did not know that one can use an empty RETURN statement in pipelined functions and I apologize to Steven Feuerstein that I did not read his blog post but I own his Oracle PL/SQL Programming book instead
Greetings from Germany and a nice weekend to all of you
Rainer
Great, code analysis doesn't grumble anymore in TOAD 16.3
Thanks and best regards
Rainer