Which code successfully calculates tax?

Which code successfully calculates tax?

Which code successfully calculates tax?

A.
CREATE OR REPLACE PROCEDURE calctax (p_no IN NUMBER)
RETURN tax IS
v_sal NUMBER;
tax Number;
BEGIN
SELECT sal INTO v_sal
FROM emp
WHERE empno = p_no;
tax := v_sal * 0.05;
END;

B.
CREATE OR REPLACE FUNCTION calctax (p_no NUMBER)
RETURN NUMBER IS
v_sal NUMBER;
BEGIN
SELECT sal INTO v_sal
FROM emp
WHERE empno = p_no;
RETURN (v_sal * 0.05);
END;

C.
CREATE OR REPLACE FUNCTION calctax (p_no NUMBER)
RETURN NUMBER IS
v_sal NUMBER;
tax NUMBER;
BEGIN
SELECT sal INTO v_sal
FROM emp
WHERE empno = p_no;
tax := v_sal * 0.05;
END

D.
CREATE OR REPLACE FUNCTION calctax (p_no NUMBER) IS
v_sal NUMBER;
tax NUMBER;
BEGIN
SELECT sal INTO v_sal
FROM emp
WHERE empno = p_no;
tax := v_sal * 0.05;
RETURN (tax);
END;

Explanation:
Incorrect Answers:
A: A RETURN clause is only valid in a function
C: Missing a RETURN clause in the executable section
D: The header portion of the function is missing the RETURN keyword.



Leave a Reply 0

Your email address will not be published. Required fields are marked *