Purpose
Ends execution of the current procedure and returns control to the calling block.
Parameters
-
result
- Must be an expression whose value can be converted to the data type specified in the RETURNS option of the containing procedure.
Example
RETURN;
RETURN(A+B);
RETURN('STRING RESULT');
RETURN('1'B);
Restrictions
A BEGIN block that is an ON-unit must not contain a RETURN statement.
Description
The RETURN statement ends execution of the current procedure and returns control to the calling block.
If a result is specified, the containing procedure must have a RETURNS option and must have been called by a function reference. In this case, the result expression is evaluated, converted to the data type specified by the RETURNS option of the PROCEDURE statement, and returned as the function value.
If a result is not specified, the containing procedure must not have a RETURNS option and can be called only by a CALL statement.
A RETURN statement executed in a BEGIN block returns from the activation of the containing procedure block and terminates any BEGIN blocks that contain the RETURN statement.