What should you correct in the above code to ensure that it executes successfully?

View the Exhibit and examine the structure of the EMPLOYEES table.

Examine the following PL/SQL block for storing the salary of all sales representatives from the
EMPLOYEES table in an associative array:
1 DECLARE
2 emp_cv SYS_REFCURSOR;
3 TYPE list IS TABLE OF emp_cv;
4 sals list;

5 BEGIN
6 OPEN emp_cv FOR SELECT salary FROM employees
7 WHERE job_id = ‘SA_REP’;
8 FETCH emp_cv BULK COLLECT INTO sals;
9 CLOSE emp_cv;
10 END;
What should you correct in the above code to ensure that it executes successfully?

View the Exhibit and examine the structure of the EMPLOYEES table.

Examine the following PL/SQL block for storing the salary of all sales representatives from the
EMPLOYEES table in an associative array:
1 DECLARE
2 emp_cv SYS_REFCURSOR;
3 TYPE list IS TABLE OF emp_cv;
4 sals list;

5 BEGIN
6 OPEN emp_cv FOR SELECT salary FROM employees
7 WHERE job_id = ‘SA_REP’;
8 FETCH emp_cv BULK COLLECT INTO sals;
9 CLOSE emp_cv;
10 END;
What should you correct in the above code to ensure that it executes successfully?

A.
Replace EMP_CV in line 3 with employees.salary%TYPE.

B.
Replace line 2 with TYPE refcur IS REF CURSOR; emp_cv refcur;.

C.
Replace BULK COLLECT in line 8 with the OPEN, FETCH, LOOP, and CLOSE statements.

D.
Replace line 2 with TYPE refcur IS REF CURSOR RETURN employees.salary%TYPE;
emp_cv refcur;.



Leave a Reply 3

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


gelete

gelete

A.

[Error] Execution (3: 27):
ORA-06550: line 3, column 27:
PLS-00488: ‘EMP_CV’ must be a type
ORA-06550: line 3, column 5:
PL/SQL: Item ignored

Replace EMP_CV in line 3 with employees.salary%TYPE.

DECLARE
emp_cv SYS_REFCURSOR;
TYPE list IS TABLE OF employees.salary%TYPE;
sals list;
BEGIN
OPEN emp_cv FOR SELECT salary FROM employees
;–WHERE job_id = ‘SA_REP’;
FETCH emp_cv BULK COLLECT INTO sals;
CLOSE emp_cv;
END;

PL/SQL procedure successfully completed.