1Z0-149 practice question 6 of 15

Which three are true about functions and procedures? (Choose three.)

Full set: 65 questions
Answer options
A: The ACCESSIBLE BY clause can be used only for procedures.
B: In a function, every execution path must lead to a RETURN statement. Correct answer
C: Both can have only constants as actual parameters for IN mode parameters.
D: Both can be invoked from within SQL statements.
E: In a procedure the RETURN statement cannot specify an expression. Correct answer
F: In a function every RETURN statement must specify an expression. Correct answer
Correct Answer:
B. In a function, every execution path must lead to a RETURN statement.; E. In a procedure the RETURN statement cannot specify an expression.; F. In a function every RETURN statement must specify an expression.
Explanation

A core principle of a PL/SQL function is that it must return a value. Therefore, the compiler enforces that every possible execution path concludes with a RETURN statement that specifies a value (an expression). This makes options B and F correct. In contrast, a procedure does not return a value. Its RETURN statement is optional and serves only to exit the subprogram immediately; it cannot include an expression, making option E correct.

Why Incorrect

A. The ACCESSIBLE BY clause is a security feature that can be applied to various program units, including both procedures and functions.
C. Actual parameters for IN mode can be variables, literals, constants, or complex expressions, not just constants.
D. Only functions that adhere to purity rules (e.g., not modifying database tables) can be invoked from SQL DML statements. Procedures cannot be called this way.

References

- Oracle Database, PL/SQL Language Reference, 19c, Chapter 9, "PL/SQL Subprograms". The sections "Function Declaration and Definition" and "Procedure Declaration and Definition" describe their fundamental differences.

- Oracle Database, PL/SQL Language Reference, 19c, "RETURN Statement". This section details the different syntax and usage of RETURN in functions (RETURN expression;) versus procedures (RETURN;).

- Oracle Database, PL/SQL Language Reference, 19c, "ACCESSIBLE BY Clause". The documentation shows this clause is applicable to standalone subprograms (functions and procedures), packages, and types.

Scroll to Top