Which two program declarations are correct for a stored program unit? (Choose two)
A.
CREATE OR REPLACE FUNCTION tax_amt
(p_id NUMBER)
RETURN NUMBER
B.
CREATE OR REPLACE PROCEDURE tax_amt
(p_id NUMBER)
RETURN NUMBER
C.
CREATE OR REPLACE PROCEDURE tax_amt
(p_id NUMBER, p_amount OUT NUMBER)
D.
CREATE OR REPLACE FUNCTION tax_amt
(p_id NUMBER)
RETURN NUMBER(10,2)
E.
CREATE OR REPLACE PROCEDURE tax_amt
(p_id NUMBER, p_amount OUT NUMBER(10, 2))
Explanation:
A: This is the correct syntax for creating a Function . The syntax for creating a function is similar to
that of creating a procedure with the addition of a RETURN statement. The following is the syntax for CREATE FUNCTION:
CREATE [OR REPLACE] FUNCTION <function name> [(parameter [mode1] datatype1,
parameter2 [mode2] datatype2 …)]
RETURN datatype
IS | AS
PL/SQL BLOCK;
C: This is the correct syntax for creating a Procedure. The syntax for creating a procedure is:
CREATE [OR REPLACE] PROCEDURE <procedure name>
[parameter1 [mode1] datatype1,
parameter2 [mode2] datatype2,
. . .)]
IS | AS
. . .
BEGIN
. . .
EXCEPTION
END <procedure name>;
Incorrect Answers:
B: This is incorrect syntax for a Procedure. Functions have a RETURN Clause, Procedures do not.
D: When you define the data type, the length of the data type is notallowed in the parameter list. If
you specify the length of a formal parameter, Oracle issues an error atcompilation time.
E: The length of the data type is not allowed in the parameter list for functions or procedures.