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
Explanation:

To answer this question, you need to understand the difference between functions and procedures in Oracle SQL. A function is a stored program unit that returns a single value, while a procedure is a stored program unit that can perform multiple actions and return multiple values. Let's go through each option to understand why it is correct or incorrect:

Option A) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER - This option is correct because it is a valid syntax for declaring a function that takes a number parameter and returns a number value.

Option B) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER - This option is incorrect because a procedure cannot use the RETURN keyword to specify the return type. A procedure can only use the OUT or IN OUT parameters to return values.

Option C) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER) - This option is correct because it is a valid syntax for declaring a procedure that takes a number parameter and returns another number value using the OUT parameter.

Option D) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2) - This option is incorrect because a function cannot use the precision and scale modifiers to specify the return type. A function can only use the data type name to specify the return type.

Option E) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) - This option is incorrect because a procedure cannot use the precision and scale modifiers to specify the OUT parameter type. A procedure can only use the data type name to specify the OUT parameter type.

The correct answer is A and C. These options are correct because they are valid syntaxes for declaring a function and a procedure respectively.

Find more quizzes: