The function "F_RET_VAL" is created which returns a NUMBER value, i.e. 1 from the function body.
2. As a PL/SQL Statement
In PL/SQL code the RETURN keyword can appear in any subprogram as a statement. As soon as it is encountered in the subprogram body, Oracle server immediately sends the execution control back to the immediate calling code or host environment. No further statements are processed in the block following the RETURN statement.
Note that a function can contain RETURN both as a clause and a statement.
In the above syntax, when the execution pointer comes to the RETURN statement, Oracle skips all subsequent statements and returns to the calling environment.
In the example below, a procedure named "P_RET_VAL" is created which returns the control to the calling environment based on the value of P_EMPNO. It returns if it is NULL.
CREATE OR REPLACE PROCEDURE P_RET_VAL (P_EMPNO NUMBER DEFAULT NULL)
Related Code Snippets:
|© 2003 - 2024 psoug.org