12 October 2010

Steven is humbled; 2nd adjustment for 11 October is made (1504)

I feel that, generally, I am pretty good at admitting that I am wrong. But for some reason, when it came to the 11 October quiz, I didn't want to admit that "see -100" was ambiguous, when combined with the actual output of the quiz, which displayed -100 twice. In any case, I have been humbled by the many comments on the previous post for this quiz. There is no doubt how many of you feel. I am not running the PL/SQL Challenge to show how right I can be, no matter what anyone else thinks. I am spending lots of my "spare" time on the PL/SQL Challenge to give you an opportunity to learn about and enjoy the PL/SQL language. So....with all my thanks and apologies, I will change the text of this quiz so that "-100" will only be displayed once. I will give everyone credit for a correct selection of the two choices that contain forward references for proc2, and I will recalculate scores. Then I will finish preparation for the Q3 championship playoff! Thanks to all of you for caring enough about the PL/SQL Challenge and your rank to make your views known. Regards, Steven

Correction for 11 October quiz - and change in policy regarding mistakes (1504)

The 11 October quiz contained a mistake - for the first four hour's of its life. I had neglected to append a ";" after the forward references in the choices, with the consequence that none of them would be correct. In the past, my policy had been this: once the quiz is published, it cannot be changed until the day is over. I have decided to change this policy. I will now fix a mistake as soon as it is discovered, usually very early after the quiz starts. That way, for the 1300+ developers who do not play the quiz in the early hours of the day (UTC time), there will be no mistake. And for the relatively few players who did play the quiz with the mistake, you will receive a correction to your score for all choices that were affected by the mistake. I did, in fact, add the ";" to the statements for the 11 October quiz and the scores of roughly 57 players will be corrected to reflect this. Chris Roderick wins an O'Reily Media for being one of the players who brought this problem to my attention. That wasn't the only concern raised by players. The question on 11 October asked, in part: 'Which of the choices offer substitutions for the /*PUBLIC*/ and /*PRIVATE*/ comments so that when the following block is executed, I will see "-100" (without the double quotes) on my screen?' In fact, the choices scored as correct each displayed -100 twice. Some of you felt that therefore all the answers were incorrect, others simply felt this was ambiguous. I disagree. You will definitely see "-100" on your screen. I do not specify that it is the only thing you will see. So there will be no change in scoring for this issue. Cheers, SF

09 October 2010

Criteria for setting difficulty level of quizzes

I received this email yesterday:

Hi Steven, Why was the question on "08th Oct 2010" on an advanced level? I ask because everyone who works with Oracle object types feels this question is more like a beginner question (just initializing and assigning). If you don't mind, can you please share as how the questions were categorized as Beginner, Intermediate and Advanced?

I certainly don't mind. One of the aspects of the PL/SQL Challenge that I like best is its transparency.We make available all sorts of data about the quizzes and the answers people have submitted. This makes it possible for you to give me feedback, help me improve the PL/SQL Challenge, and see how other players are doing.

So, first, thanks for asking about this specific quiz. It should not have been marked as an Advanced question. As to how it got that way, I have generally been assigning a difficulty level of at least Intermediate for any areas of functionality that are rarely used, such as object types.

Your email has me re-thinking this approach, though. It seems like what I should do is rank the difficulty level within the context of the functionality area, at least for a feature as broad as object types. There are beginner questions on object types and, you are right - this is one of them.

So here's what I am going to do:

1. Change the difficulty level on this question to Beginner (everyone's scores will be decreased, but your rankings will not be affected).

2. Be more discriminating about how I set that difficulty level. It may be true that few developers use object types, but it is a part of the core PL/SQL language and has been available for years. There is no reason that we should not all be expected to have at least a rudimentary awareness of it.

Many thanks and please keep that feedback rolling in,
Steven

08 October 2010

Beware late changes in mind! 7 October quiz scored incorrectly (1484)

The question for the 7 October quiz was: Which of the following blocks, when executed, satisfy these two requirements:
1. It will display the string "50" (without the double quotes).
2. Every statement in the block is required for the block to compile successfully.
My main objective with this lesson was to remind everyone that you do not need to (and should not) declare a variable for the iterator in a FOR loop. That is done implicitly for us by Oracle. And the way I decided to get the point across was to add that second requirement "Every statement in the block is required for the block to compile successfully." That is, the choice in which that "extra" variable was declared was scored as incorrect:
DECLARE
  l_iterator   PLS_INTEGER;
BEGIN
  FOR l_iterator IN 1 .. 100
  LOOP
     IF l_iterator = 50
     THEN
        DBMS_OUTPUT.put_line (l_iterator);
     END IF;
  END LOOP;
END;
/
So why is there a problem with this quiz? Because another choice was as follows:
DECLARE
  l_counter   PLS_INTEGER := 0;
BEGIN
  FOR l_iterator IN 1 .. 100
  LOOP
     l_counter := l_counter + 1;
  END LOOP;

  DBMS_OUTPUT.put_line (l_counter / 2);
END;
/
This block of code avoids declaring l_iterator, and displays "50." Originally (up until more or less the "last minute"), I scored this as correct. Then, as I did my just-before-quiz-starts review of the quiz, I said to myself: "Wait a minute, I could remove that DBMS_OUTPUT.PUT_LINE call and the block would still compile successfully! So this is incorrect." So I changed the way I scored that choice. I think that this change would have made sense if the question did not say "when executed", but that clause clearly indicates that both requirements need to be made at the time the block executes. The lesson I learned (and re-learn, sadly)? Do not change your mind late in the process, certainly not without discussing the change, and motivation for it, with someone else. To conclude: this choice was scored improperly. I will change it from "incorrect" to "correct," and I will also change the explanation to explain clearly why this should be considered correct. And then I will update scores and re-rank. Congratulations to Oliver Dimalanta, one of over a dozen players who reported this mistake. Oliver receives his choice of an O'Reilly Media ebook.

07 October 2010

Input needed for the Past Quizzes page

Dear players,

I plan for the 1.7 release of PL/SQL Challenge (tentatively scheduled for 23 October) to improve the quantity and quality of information shown on the Past Quizzes page.

Once this page is re-designed, I then plan to send out the same information in the "yesterday's quiz" email.

So if you have any thoughts about how you'd like to see this page and/or the daily email changed, please post your ideas here (or, if you do not have a Blogger/Gmail account, send them directly to steven@stevenfeuerstein.com).

Many thanks,
Steven Feuerstein

05 October 2010

When is %ROWTYPE used to define the record structure? (1461)

The 4 October quiz recorded as correct the following statement: "You can declare a record based on a table, so that every time you compile the block in which the record is defined, the PL/SQL compiler defines a field in the record for each column in the table, with matching name and datatype." One player wrote to me with the following comment (I bolded the key words):
Steven, in the explanation for this choice you write "You can declare a record based on a table, so that every time you compile the block in which the record is defined, the PL/SQL compiler defines a field in the record for each column in the table, with matching name and datatype." You show an anonymous block illustrated this, i don't know if this is "almost" true, coz i can create a procedure, compiled, modified the table, and i don't need to compiled again to take effect the %ROWTYPE. i think is more like "that every time you -execute- the block in which the record is defined, the PL/SQL compiler defines a field in the record for each column in the table, with matching name and datatype."
This is definitely not true. The "lookup" of the structure of the table, view or cursor, to then use to define the fields of a record type in PL/SQL definitely happens at compile time. When you are executing an anonymous block, the PL/SQL compiler must first compile that block before it is executed. That's when the lookup occurs. If you have defined a stored program unit, like a procedure with a %ROWTYPE declaration, then whenever that program unit is re-compiled, Oracle again "looks up" the structure of table, view or cursor. Some of the confusion might arise from the fact that you do not have to explicitly recompile your program unit after you change a table referenced in %ROWTYPE. Oracle automatically marks that program unit as invalid and will also automatically attempt to recompile it the next time you try to use that program unit. But there is no doubt that this is compile-time and not run-time behavior. There is no way that you or Oracle would want to slow down production performance by looking up the structure of tables and views every time the program unit is executed! Cheers, SF

Oh, no - Ambiguity strikes again in the 4 October quiz (1461)

The English language (or, rather, my use of it) strikes again! The 4 October quiz was one of those non-code, all-words quiz and it burned me/us again. The quiz question was: "Which of the following statements about PL/SQL records are correct?" Players complained about three (yes, three) of the choices. But I don't agree with all complaints. :-) Let's take a closer look.... 1. "A record contains an audio or video recording for storage in the Oracle database." As one player wrote: "I chose to read it as: 'A record may contain an audio or video recording...' Obviously, it is a column within the record that contains the multimedia experience, which means the record also does.' My response to this interpretation is: I disagree. That is, I suppose I understand why you might read the choice this way, but I do not believe it is a reasonable interpretation - I don't think there is ambiguity here. The question makes it clear that I am asking you to identify correct statements about records in general. It is true that a record might contain a "recording"/BLOB field. But it doesn't have to and the choice clearly (or at least, clearly enough, to my mind). This statement is not true for "PL/SQL records" as the question asks. Furthermore, it should be well understood that a PL/SQL record is not necessarily stored in the Oracle database (as a row in a table). So this statement was incorrect on several counts. I will not change scoring for this choice. Another player wrote about this choice: "I would have preferred this option to say 'A record ALWAYS contains a video/audio recording...' to remove the ambiguity." Yes, that would certainly be more explicit, but I also feel that it would "give too much away." 2. 'While it is possible to assign NULL to a record, it is not possible to check to see if every field in the record is null using the "IS NULL" operator.' Sigh. Yes, here we have an ambiguity that I cannot explain away. I wanted you to know or learn that you cannot use the IS NULL operator with the record variable itself. My decision to include "every field in the record," however, clearly invites you to interpret this choice as correct, in that you can check the contents of each field using IS NULL (or, if a field is a record, you could in turn use IS NULL on each of its fields, etc.). I should have made it clear that I wanted the IS NULL to be applied to the record. I did not, and so I will give all players credit for this choice, change the text to make it more explicit, and change all of your answers to indicate "correct" for this choice. 3. "You cannot check for equality between two records using the "=" operator. " One player suggested that this choice has the same ambiguity as #2. That is, you can use "=" to compare the values of individual fields of the record. I disagree with this interpretation. I believe it is quite clear that this choice asks you to decide if you can use the "=" operator with the records themselves, not their fields. I will not changes scores on this choice. So, sorry about that and on to the next quiz! Fortunately, it has code in it. :-) Cheers, Steven Feuerstein