1

Just a question since I can't seem to find the answer somewhere else.

So I got an PL/SQL function which contains a nested block, and within the 2nd level block it got a return value of 1. Does this mean that it will not proceed to the next block and return the value 1 or it will only terminate the current block?

Thanks!

Sample structure for illustration:

FUNCTION EXAMPLE ( sample_variable VARCHAR2)
    RETURN NUMBER
IS
    BEGIN 
       BEGIN
          /*CODES HERE*/
       EXCEPTION
           WHEN OTHERS THEN
           RETURN 1; //HERE IS THE QUESTION. WHEN I GOT HERE IN RETURN DOES IT TERMINATE THE WHOLE 
                     //FUNCTION AND RETURN 1 OR IT WILL STILL CONTINUE TO BLOCK 2*/
       END;
       BEGIN /*BLOCK 2*/
          /*OTHER CODES HERE*/
          RETURN 2;
       END;
    END
 END EXAMPLE;

1 Answer 1

3

Terminates the whole function.

From oracle docs:

In a function, the RETURN statement assigns a specified value to the function identifier and returns control to the invoker, where execution resumes immediately after the invocation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.