Which two program declarations are correct for a stored program unit? (Choose two)

  1. a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER

  2. b) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER

  3. c) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)

  4. d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2)

  5. e) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2))


Correct Option: A,C

AI Explanation

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

Option A) a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER - This option is correct because it declares a stored function named "tax_amt" that takes a parameter "p_id" of type NUMBER and returns a value of type NUMBER.

Option B) b) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER - This option is incorrect because it declares a stored procedure, not a function. The keyword "RETURN NUMBER" is not applicable for a procedure declaration.

Option C) c) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER) - This option is correct because it declares a stored procedure named "tax_amt" that takes two parameters "p_id" and "p_amount". The "p_amount" parameter is an OUT parameter, which means it will be used to return a value.

Option D) d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2) - This option is incorrect because it declares a stored function with a return type of NUMBER(10,2), which is not valid syntax. The return type should be just NUMBER without any precision or scale specified.

Option E) e) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) - This option is incorrect because it declares a stored procedure with an OUT parameter "p_amount" of type NUMBER(10, 2), which is not valid syntax. The parameter type should be just NUMBER without any precision or scale specified.

The correct answers are A) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER and C) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER). These options correctly declare a stored function and a stored procedure, respectively.

Find more quizzes: