exam questions

Exam 1z0-148 All Questions

View all questions & answers for the 1z0-148 exam

Exam 1z0-148 topic 1 question 26 discussion

Actual exam question from Oracle's 1z0-148
Question #: 26
Topic #: 1
[All 1z0-148 Questions]

The STUDENTS table with column LAST_NAME of data type VARCHAR2 exists in your database schema.
Examine this PL/SQL block:

Which two actions must you perform for this PL/SQL block to execute successfully?

  • A. Replace the FOR loop with FOR name_rec IN names_varray.FIRST .. names_varray.LAST LOOP.
  • B. Replace the L_NAME_TYPE declaration with TYPE 1_name_type IS VARRAY (25) OF SYS_REFCURSOR;
  • C. Add name_rec name_cur%ROWTYPE; at the end of the DECLARE section.
  • D. Replace the NAMES_VARRAY declaration with names_varray 1_name_type := 1_name_type ();
  • E. Replace the NAMES_VARRAY declaration with names_varray 1_name_type := null;
  • F. Add names_varray.EXTEND after the FOR …LOOP statement.
Show Suggested Answer Hide Answer
Suggested Answer: EF 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
orakell
Highly Voted 5 years, 2 months ago
DF, not EF.
upvoted 7 times
...
Rakeshpro
Most Recent 2 years, 4 months ago
Selected Answer: DF
DECLARE CURSOR l_name_cur IS SELECT LAST_NAME FROM EMPLOYEES FETCH NEXT 25 ROWS ONLY; TYPE l_name_type IS VARRAY(25) OF EMPLOYEES.last_name%type; --names_array l_name_type; --WRONG --Reference to uninitialized collection names_array l_name_type := l_name_type(); v_index INTEGER := 0; BEGIN FOR name_rec IN l_name_cur LOOP names_array.EXTEND(); -- DONT OMIT IT, Or will get ERROR: Subscript beyond count v_index := v_index + 1; names_array(v_index) := name_rec.last_name; DBMS_OUTPUT.PUT_LINE(names_array(v_index)); END LOOP; END;
upvoted 1 times
...
chrishillinger
2 years, 5 months ago
Selected Answer: DF
Initialize correctly and you need to extend VARRAYs
upvoted 1 times
...
Benjmaz
4 years ago
D,F Working code below DECLARE CURSOR l_name_cur IS SELECT LAST_NAME FROM SIS.STUDENTS; TYPE l_name_type IS VARRAY(25) OF SIS.STUDENTS.last_name%type; names_array l_name_type := l_name_type(); v_index INTEGER := 0; BEGIN FOR name_rec IN l_name_cur LOOP names_array.EXTEND(); v_index := v_index + 1; names_array(v_index) := name_rec.last_name; DBMS_OUTPUT.PUT_LINE(names_array(v_index)); END LOOP; END; /
upvoted 3 times
...
sudhirdavim
4 years, 1 month ago
DF is correct.
upvoted 1 times
...
CosminCof
4 years, 2 months ago
DF is correct
upvoted 1 times
...
peguynya
4 years, 6 months ago
D,F is the corrct answer
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago