View the Exhibit to examine the PL/SQL block.
Which statement is true about the execution of the PL/SQL block?
A.
It executes successfully and gives the desired output.
B.
It does not execute because the definition of type population is indexed by VARCHAR2.
C.
It executes, and the string keys of an associative array are not stored in creation order, but in
sorted order.
D.
It does not execute because the value that is once assigned to the element of the associative
array cannot be changed.
C,
it is example from oracle documentation
C
c
I think this is a multi choice question. Answer is A and C.
C
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005
Example 5-1 Associative Array Indexed by String
Result:
Population of Megalopolis is 1000000
Population of Midland is 750000
Population of Smallville is 2001
C
A and C
A and C
=========================================================
DECLARE
TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
salary_list salary;
name VARCHAR2(20);
BEGIN
— adding elements to the table
salary_list(‘Zzer’) := 100;
salary_list(‘Rajnish’) := 62000;
salary_list(‘Minakshi’) := 75000;
salary_list(‘Martin’) := 100000;
salary_list(‘James’) := 78000;
— printing the table
name := salary_list.FIRST;
WHILE name IS NOT null LOOP
dbms_output.put_line
(‘Salary of ‘ || name || ‘ is ‘ || TO_CHAR(salary_list(name)));
name := salary_list.NEXT(name);
END LOOP;
END;
/
AC correct and your code is corrected to use, you are wellcome
DECLARE
TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
salary_list salary;
name VARCHAR2(20);
BEGIN
–adding elements to the table
salary_list(‘Zzer’) := 100;
salary_list(‘Rajnish’) := 62000;
salary_list(‘Minakshi’) := 75000;
salary_list(‘Martin’) := 100000;
salary_list(‘James’) := 78000;
— printing the table
name := salary_list.FIRST;
WHILE name IS NOT null LOOP
dbms_output.put_line (‘Salary of ‘ || name || ‘ is ‘ || TO_CHAR(salary_list(name)));
name := salary_list.NEXT(name);
END LOOP;
END;
C
The answer is AC.
You have to choose two answers.
The question is ‘which statement’ not ‘which statements’. It’s not multi choice question. Only answer C is correct.
The output:
————-
Salary OF JamesIS 78000
Salary OF MartinIS 100000
Salary OF MinakshiIS 75000
Salary OF RajnishIS 62000
Salary OF ZzerIS 100
C
Example 5-1 defines a type of associative array indexed by string, declares a variable of that type, populates the variable with three elements, changes the value of one element, and prints the values (in sort order, not creation order).
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS99969
Today, i passed the examen. All questions are still valid (in The Netherlands).
With this question you must choose two answers: AC