Vous êtes sur la page 1sur 3

Test: Quiz: Cursors with Parameters 1.

You want to use explicit cursors to fetch and display all the countries in a specific region. There are 19 rows in the WF_WORLD_REGIONS table. You want to use a different region each time the cursor is opened. How many cursors shou ld you declare? Mark for Review (1) Points 19 cursors, all in the same PL/SQL block. 19 cursors in 19 PL/SQL blocks (one in each block). 20 cursors, in case an extra row is inserted into WF_WORLD_REGIONS later . One cursor with a parameter in the WHERE clause. (*) None of the above.

Correct 2. Using parameters with a cursor, you can open and close the cursor sever al times in a block, returning a different active set each time. True or False? Mark for Review (1) Points True (*) False

Correct 3. The following cursor has been declared: CURSOR emp_curs (p_dept_id employees.department_id%TYPE, p_job_id employees.job_id%TYPE) IS SELECT * FROM employees WHERE department_id = p_dept_id AND job_id = p_job_id; Which of the following will correctly open the cursor? Mark for Review (1) Points OPEN emp_curs(20);

FOR emp_rec IN emp_curs(20) LOOP ... OPEN emp_curs('IT_PROG', 20); FOR emp_rec IN emp_curs(20,'IT_PROG') LOOP ... (*) FOR emp_rec IN emp_curs(p_dept_id p_job_id) LOOP ...

Correct 4. Look at the following code: DECLARE CURSOR emp_curs (p_dept_id employees.department_id%TYPE) IS SELECT * FROM employees WHERE department_id = p_dept_id; v_emp_rec emp_curs%ROWTYPE; v_deptid NUMBER(4) := 50; BEGIN OPEN emp_curs( -- Point A --); .... You want to open the cursor, passing value 50 to the parameter. Which of the fol lowing are correct at Point A? Mark for Review (1) Points 50 v_deptid 100 / 2 All of the above. (*)

Correct 5. What is wrong with the following cursor declaration? SELECT * FROM departments WHERE location_id = p_loc_id; Mark for Review (1) Points You cannot reference a cursor parameter in a WHERE clause. The parameter should be coded as: (p_loc_id NUMBER) (*)

The parameter should be coded as: (p_loc_id IN NUMBER) Nothing is wrong, the cursor declaration is correct.

Correct

Vous aimerez peut-être aussi