Oracle Database 11g: Program with PL/SQL — Question 41
In which of the following scenarios would you recommend using associative arrays?
Answer options
- A. When you want to retrieve an entire row from a table and perform calculations
- B. When you know the number of elements in advance and the elements are usually accessed sequentially
- C. When you want to create a separate lookup table with multiple entries for each row of the main table, and access it through join queries
- D. When you want to create a relatively small lookup table, where the collection can be constructed on memory each time a subprogram is invoked.
Correct answer: D
Explanation
The correct answer is D because associative arrays are ideal for situations where the data structure is small and can be recreated in memory as needed. Option A is inappropriate as it involves full row retrieval, which is not the primary function of associative arrays. Option B suggests sequential access, which is more suited to regular arrays. Option C involves complex relationships and multiple entries, which do not align with the use case for associative arrays.