CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG (V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE) RETURN NUMBER IS V_AVG NUMBER; BEGIN SELECT HITS / AT_BATS INTO V_AVG FROM PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID; RETURN (V_AVG); END; Which statement will successfully invoke this function in SQL *Plus

  1. SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT;

  2. EXECUTE CALC_PLAYER_AVG(31);

  3. CALC_PLAYER(‘RUTH’);

  4. CALC_PLAYER_AVG(31);


Correct Option: A

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT; This option is correct because it correctly invokes the function CALC_PLAYER_AVG by passing the PLAYER_ID column from the PLAYER_BAT_STAT table as the argument.

Option B) EXECUTE CALC_PLAYER_AVG(31); This option is incorrect because the EXECUTE statement is not supported in SQL *Plus. Instead, you should use a SELECT statement to invoke the function.

Option C) CALC_PLAYER('RUTH'); This option is incorrect because it does not match the function name. The correct function name is CALC_PLAYER_AVG.

Option D) CALC_PLAYER_AVG(31); This option is incorrect because it does not include the necessary SELECT statement to invoke the function. The correct syntax is to use a SELECT statement as shown in option A.

The correct answer is A. This option is correct because it uses the correct function name and syntax to invoke the function CALC_PLAYER_AVG.

Find more quizzes: