Oracle Database: Program with PL/SQL — Question 10
Examine this code:
CREATE TYPE list_typ IS TABLE OF NUMBER;
/
DECLARE -
l_list list_typ := list_typ ();
Which two executable sections will display the message TRUE?
Answer options
- A. BEGIN IF l_list.LIMIT IS NOT NULL THEN DBMS_OUTPUT.PUT_LINE (TRUE); END IF; END;
- B. BEGIN l_list.EXTEND; IF l_list.PRIOR (1_list.FIRST) IS NULL THEN DBMS_OUTPUT.PUT_LINE (TRUE); END IF; END;
- C. BEGIN l_list.EXTEND; IF l_list IS EMPTY THEN DBMS_OUTPUT.PUT_LINE (TRUE); END IF; END;
- D. BEGIN IF l_list.FIRST IS NULL THEN DBMS_OUTPUT.PUT_LINE (TRUE); END IF; END;
- E. BEGIN IF l_list.FIRST =1 THEN DBMS_OUTPUT.PUT_LINE (TRUE); END IF;
Correct answer: B, E
Explanation
The correct answers B and E will display TRUE because B checks if the first item is NULL after extending the list, and E checks if the first item equals 1. Options A and D will not output TRUE as they check conditions that do not apply to an empty list, and C incorrectly checks if the list is empty after extending it.