Two players complained that they don't think it makes sense for a quiz to test one's knowledge of a bug. I offer their comments below and will leave it to the author first to reply with her own "story behind the quiz", and of course publish any other comments as well.
"While this is obviously known behaviour, I feel a bit ripped off in getting this wrong. I answered what was logical (to me) from the code - the array definition says the index must be -1/0/1, bulk collect will use index values 1/2/3, so bulk collect will error. To me, the behaviour of bulk collect ignoring the index by's data type constraints seems like a bug. If this is documented by Oracle as being expected behaviour, it would be good to have that reference in the answer. If not, it seems a bit rough to mark people incorrect for not knowing about a bug."
and with some code, too:
When you run the code of this quiz, Oracle does actually make from an INDEX BY SIGNTYPE table an 'read-only' INDEX BY PLS_INTEGR table. You can only change the values for index (-1, 0, 1). See the following code:
DECLARE TYPE t_bug_type IS TABLE OF all_source%ROWTYPE INDEX BY SIGNTYPE; v_bugs t_bug_type; v_ndx PLS_INTEGER; BEGIN BEGIN SELECT * BULK COLLECT INTO v_bugs FROM all_source ORDER BY owner, name, line; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('ERROR'); END; DBMS_OUTPUT.put_line ( 'First = ' || v_bugs.FIRST || ' Last = ' || v_bugs.LAST || ' Count = ' || v_bugs.COUNT); v_ndx := v_bugs.FIRST; DBMS_OUTPUT.put_line (v_bugs (v_ndx).text); v_ndx := v_bugs.LAST; DBMS_OUTPUT.put_line (v_bugs (v_ndx).text); BEGIN v_bugs (v_bugs.LAST).text := 'Oracle has many bugs !!'; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ( 'You should not create quizzes based on bugs !!'); END; END; /
Oracle has many bugs, in my opinion it is not intended to make quizzes based on bugs.
So...what do you think?