exam questions

Exam 1z0-148 All Questions

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

Exam 1z0-148 topic 1 question 39 discussion

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

In your schema, the DEPARTMENTS table contains the columns DEPARTMENT_ID and DEPARTMENT_NAME.
You want to display the department name for existing department id 10.
With SERVEROUTPUT enabled, which two blocks of code will give the required output?

  • A. DECLARE TYPE dept_cur IS REF CURSOR; cv1 dept_cur; v_dept_name departments. department_name%TYPE; BEGIN OPEN cv1 FOR SELECT department_name FROM departments WHERE department_id=10; IF cv1 IS NOT NULL THEN FETCH cv1 INTO v_dept_name; DBMS_OUTPUT.PUT_LINE (v_dept_name); END IF CLOSE cv1; END;
  • B. DECLARE TYPE dept_cur IS REF CURSOR RETURN departments%ROWTYPE; cv1 dept_cur; v_dept_name departments.department_name%TYPE; BEGIN OPEN cv1 FOR SELECT * FROM departments WHERE department_id=10; FETCH cv1. department_name INTO v_dept_name; DBMS_OUTPUT.PUT_LINE (v_dept_name); CLOSE cv1; END;
  • C. DECLARE TYPE names_t IS TABLE OF SYS_REFCURSOR INDEX BY PLS_INTEGER; cv1 names_t; v_dept_name departments.department_name%TYPE; BEGIN OPEN cv1 FOR SELECT department_name FROM departments WHERE department_id=10; FETCH cv1 INTO v_dept_name; DBMS_OUTPUT.PUT_LINE (v_dept_name); CLOSE cv1; END;
  • D. DECLARE cv1 SYS_REFCURSOR; v_dept_name departments.department_name%TYPE; BEGIN EXECUTE IMMEDIATE BEGIN OPEN: cv1 FOR SELECT department_name FROM departmnets WHERE department_id=10: END; USING IN cv1; FETCH cv1 INTO v_dept_name; DBMS_OUTPUT.PUT_LINE (v_dept_name); CLOSE cv1;
Show Suggested Answer Hide Answer
Suggested Answer: CD 🗳️

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
AD. Not CD and not BD.
upvoted 6 times
...
Rakeshpro
Most Recent 2 years, 4 months ago
A. DECLARE TYPE dept_cur IS REF CURSOR; D. DECLARE cv1 SYS_REFCURSOR; Correct syntax for REF CURSOR
upvoted 1 times
...
chrishillinger
2 years, 5 months ago
Selected Answer: AD
AD is correct
upvoted 1 times
...
CosminCof
4 years, 2 months ago
AD correct
upvoted 2 times
...
kahabe59
4 years, 11 months ago
A and D are correct. B returns: invalid reference to variable cv1 C returns: Index Tables of Cursor Variables are disallowed
upvoted 3 times
...
Tinamoran
5 years, 3 months ago
B and D are the right answer
upvoted 1 times
Katana19
5 years, 3 months ago
nope !
upvoted 3 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