Which code should be inserted to display the collection contents?

Examine the structure of the EMP table:
Name                    Null?            Type
——————    ————–    ———————
EMPNO               NOT             NULL NUMBER (4)
ENAME                                   VARCHAR2 (10) SAL                NUMBER (7, 2)
Examine this code:

Which code should be inserted to display the collection contents?
A. 1_indx := 1_list.FIRST;
WHILE (1_indx IS NOT NULL) LOOP
DBMS_OUTPUT.PUT_LINE (1_indx || ‘ ‘ || 1_list (1_indx));
1_indx := 1_emp.NEXT (1_indx); END LOOP;
B. FOR indx IN 1_list. COUNT .. -1 LOOP
DBMS_OUTPUT.PUT_LINE (indx | | ‘ ‘ | | 1_list (indx));
END LOOP;
C. FOR indx IN -1 .. 1_list.LIMIT LOOP
DBMS_OUTPUT.PUT_LINE (indx | | ‘ ‘ | | 1_list (indx) );
END LOOP;
D. FOR indx IN 1_list.FIRST . . 1_list.LAST LOOP
DBMS_OUTPUT.PUT_LINE (indx | | ‘ ‘ | | 1_list (indx)); END LOOP;

Download Printable PDF. VALID exam to help you PASS.

6 thoughts on “Which code should be inserted to display the collection contents?

  1. only D

    declare
    type list_typ is table of number index by PLS_INTEGER ;
    l_LIST list_typ;
    l_indx number ;
    begin
    select SAL bulk collect into l_list from emp;
    for indx in l_list.first .. l_list.last loop
    if l_list(indx)<1000 then
    l_list(indx*-1) := l_list(indx);
    l_list.delete(indx);
    end if;
    end loop;

    FOR indx IN l_list.FIRST .. l_list.LAST LOOP
    DBMS_OUTPUT.PUT_LINE (indx ||' '|| l_list (indx)); END LOOP;

    end;

  2. A:
    l_index := l_list.first;
    while l_index is not null
    loop
    dbms_output.put_line(l_index || ‘ ‘ || l_list(l_index));
    l_index := l_list.next(l_index);
    end loop;

    D will fail on missing 0 array index l_list(0)

  3. D

    A. Failed with
    ORA-06550: line 20, column 13:
    PLS-00201: identifier ‘L_EMP.NEXT’ must be declared

  4. clear code
    l_indx := l_list.FIRST;
    WHILE (l_indx IS NOT NULL) LOOP
    DBMS_OUTPUT.PUT_LINE (l_indx || ‘ ‘ || l_list (l_indx));
    l_indx := l_list.NEXT (l_indx);
    END LOOP;

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.