Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

Part Number E10472-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

RETURN Statement

The RETURN statement immediately completes the execution of a subprogram and returns control to the invoker. Execution resumes with the statement following the subprogram call. In a function, the RETURN statement also sets the function identifier to the return value.

Note:

The RETURN statement differs from the RETURN clause in a function heading, which specifies the data type of the return value.

Topics:

Syntax

return_statement ::=

return_statement
Description of the illustration return_statement.gif

See expression ::=.

Semantics

expression

Required when the RETURN statement is in a function, but not allowed when the RETURN statement is in a procedure or anonymous block.

When the RETURN statement runs, the value of expression is assigned to the function identifier; therefore, the value of expression must have a data type that is compatible with the data type in the RETURN clause of the function (see Table 3-10, "Possible Implicit PL/SQL Data Type Conversions"). For information about expressions, see "Expression".

Usage

A subprogram or anonymous block can contain multiple RETURN statements. In an anonymous block, the RETURN statement exits its own block and all enclosing blocks.

In a function, at least one execution path must lead to a RETURN statement. Otherwise, PL/SQL raises an exception at run time.

Examples

Related Topics

In this chapter:

In other chapters: