Examine the code and state which of the following options is correct? CREATE OR REPLACE PACKAGE bonus IS g_max_bonus NUMBER := .99; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER; FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER; END; / CREATE OR REPLACE PACKAGE BODY bonus IS v_salary employees.salary%TYPE; v_bonus employees.commission_pct%TYPE; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER - 7 - IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employee_id = p_emp_id; RETURN v_bonus * v_salary; END calc_bonus FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employees RETURN v_bonus * v_salary + v_salary; END cacl_salary; END

  1. You can call the BONUS.CALC_SALARY packaged function from an INSERT command against the EMPLOYEES table.

  2. You can call the BONUS.CALC_SALARY packaged function from a SELECT command against the EMPLOYEES table.

  3. You can call the BONUS.CALC_SALARY packaged function form a DELETE command against the EMPLOYEES table.

  4. You can call the BONUS.CALC_SALARY packaged function from an UPDATE command against the EMPLOYEES table.


Correct Option: B

AI Explanation

To answer this question, let's examine the code provided.

The given code defines a package called bonus with two functions: calc_bonus and calc_salary. The package body then implements these functions.

Option A) You can call the BONUS.CALC_SALARY packaged function from an INSERT command against the EMPLOYEES table. This option is incorrect because the calc_salary function is not designed to be used in an INSERT command. It is meant to calculate and return the salary based on the employee ID.

Option B) You can call the BONUS.CALC_SALARY packaged function from a SELECT command against the EMPLOYEES table. This option is correct. The calc_salary function can be called in a SELECT command to retrieve the calculated salary for a specific employee ID.

Option C) You can call the BONUS.CALC_SALARY packaged function from a DELETE command against the EMPLOYEES table. This option is incorrect. The calc_salary function is not designed to be used in a DELETE command. It is meant to calculate and return the salary based on the employee ID.

Option D) You can call the BONUS.CALC_SALARY packaged function from an UPDATE command against the EMPLOYEES table. This option is incorrect. The calc_salary function is not designed to be used in an UPDATE command. It is meant to calculate and return the salary based on the employee ID.

Therefore, the correct answer is B) You can call the BONUS.CALC_SALARY packaged function from a SELECT command against the EMPLOYEES table.

Find more quizzes: