my_collection (1) := 10;"Which of the statements correctly describe a step I must take after declaring my collection and before I can successfully execute the above statement?" And we at PL/SQL Challenge claimed that the only correct answer was: "You must initialize the collection by assigning it a value returned by a call to a function provided by Oracle that has the same name as the type from which the collection was declared." Two players wrote to question this viewpoint as follows: 1. "Hi, I disagree with your answer to yesterdays quiz. You've checked the "You must initialize...." answer as correct. I think it's not a complete answer, because it lacks the the use of "extend". I can bypass using extend by using a dummy value in the constructor. But that is IMO such a bad practice that I don't consider it a correct way to do it." 2. "Do we must initialize nested table? Yes. Do we must do it by calling default constructor? No. We can call another function returning initialized collection.We can construct a collection using bulk collect. So we indeed do not must call default constructor.Although it's a typical way we have more choices.That is why i consider your answer literally incorrect." Here is our answer to these objections: 1. We never said that calling a constructor function was the only thing you had to do before you could execute the assignment. It is, certainly, "a step I must take." The player is right; a call to the EXTEND will almost always be needed as well. But that doesn't make the choice incorrect. 2. The player is right. You could call your own function to initialize the collection; you could also avoid the need to call a constructor by populating the collection with a call to BULK COLLECT. Having said that, please refer back to this assumption which appears before you take each quiz: "The session and the environment in which the quiz code executes has enabled output from DBMS_OUTPUT, and can reference only those datatypes, programs and database objects defined in the context of the quiz or are available in a default installation of the Oracle instance." This means that unless we explicitly say that we have created in the context of this question another such function, it does not exist and you cannot assume its use in the answer. As far as BULK COLLECT goes, in general, that will allow you to avoid the need to call a constructor, but in this particular case (performing a scalar assignment), that does not apply. So we believe that while these are interesting and informed questions to raise about the 21 June quiz, all your answers were scored correctly. What do you think?
22 June 2010
Questions raised about 21 June Quiz - what do you think?(409)
The question was: "I declare a nested table or varray of numbers. I then want to assign the number 10 to index value 1, as in: