The 15 June quiz tested your knowledge of the ability to pass arguments to parameterized cursors.
We scored as correct the following choice:
DECLARE
l_filter VARCHAR2 (100) := 'M%';
CURSOR parts_cur (filter_in IN OUT VARCHAR2)
IS
SELECT *
FROM plch_parts
WHERE partname LIKE filter_in
ORDER BY partnum;
l_part plch_parts%ROWTYPE;
BEGIN
OPEN parts_cur (l_filter);
LOOP
FETCH parts_cur INTO l_part;
EXIT WHEN parts_cur%NOTFOUND;
sys.DBMS_OUTPUT.put_line (l_part.partnum);
END LOOP;
CLOSE parts_cur;
END;
even though Oracle documentation specifies that a cursor parameter may only be of mode IN (not IN OUT).
As we noted in the answer: "This choice specifies IN OUT for the mode. Oracle documentation only shows the use of the IN mode, but Oracle doesn't complain about IN OUT, and it certainly doesn't change the value of the variable."
A player wrote with this complaint:
This choice was not supposed to work, both by Oracle PL/SQL Documentation below: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/static.htm#CIHFAHFE http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/explicit_cursor.htm#i33637 ( the railroad schema explicitly shows IN parameter mode as the only legal one ). and also even more explicitly by what is stated in your book: PL/SQL Programming 5-th edition, Chapter15, Working With Explicit Cursor, Cursor Parameter Modes, page.491-492, where it is clearly stated that: "You cannot specify OUT or IN OUT modes for cursor parameters". This being said and completely logic, it is however strange that both choices [6938] and [6939] do compile without error! Regarding choice 6938, since it also returns the expected result ( !!! ). I think that this choice should be rescored for ALL players and considered as INCORRECT. The same is in fact required for choice 6939, but that one is incorrect anyway (it does not display the expected output), but in principle is as wrong as the previous one. I am pretty sure that many players will raise the same objection. This is not a feature not specified in the documentation, as we have encountered some in our quizzes, but clearly a behavior that contradicts the documented (and logical) one.
And my response: first, it sure is a drag when someone quotes your own book at you! :-) And in fact what this player has pointed out is a
bug in my book. In fact, you
can specify OUT or IN OUT. Oracle does not stop you from doing this; the documentation simply does not indicate that it is accepted by the compiler. So I will fix that in my book.
Second, if the only correct choice in this quiz was the IN OUT parameter (and it was a "one choice correct only" question), then you should all be upset with me; that
would be a "trick question." It is, however, just one of several correct choices. So, yes, you are "penalized" if you simply checked the documentation and answered according to it, rather than actually trying it out before you submitted your answer. But now you also know this is possible and it may be something you look out for in your code - that is, it may be "lurking" in your code and should be removed.
And that is part of the point of the PL/SQL Challenge - to extend your awareness of the day-to-day realities of the language. In conclusion, I do not believe a re-scoring is in order.