nerdexam
Oracle

1Z0-146 · Question #117

View the Exhibit and examine the structures of the EMPLOYEES and DEPARTMENTS tables. Examine the PL/SQL block that you execute to find the average salary for employees in the 'Sales' department…

The correct answer is A. It executes successfully and gives the correct output. See the full explanation below for the reasoning.

Question

View the Exhibit and examine the structures of the EMPLOYEES and DEPARTMENTS tables. Examine the PL/SQL block that you execute to find the average salary for employees in the 'Sales' department:

DECLARE TYPE emp_sal IS TABLE OF employees.salary%TYPE INDEX BY VARCHAR2(20); v_emp_sal emp_sal; PROCEDURE get_sal(p_dept_name VARCHAR2, p_arr OUT emp_sal) IS BEGIN SELECT AVG(salary) INTO p_arr(p_dept_name) FROM employees WHERE department_id= (SELECT department_id FROM departments WHERE department_name=p_dept_name); END get_sal; BEGIN get_sal('Sales',v_emp_sal); DBMS_OUTPUT.PUT_LINE( v_emp_sal('Sales')); END; / What is the outcome?

Exhibit

1Z0-146 question #117 exhibit

Options

  • AIt executes successfully and gives the correct output.
  • BIt generates an error because the associative array definition is not valid.
  • CIt generates an error because an associative array cannot be passed to a procedure in OUT mode.
  • DIt generates an error because an associative array cannot be used with the SELECT INTO statement.

How the community answered

(41 responses)
  • A
    80% (33)
  • B
    2% (1)
  • C
    12% (5)
  • D
    5% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-146 Practice