80
PL/SQL GOTO Statement
In PL/SQL, GOTO statement makes you able to get an unconditional jump from the GOTO to a specific executable statement label in the same subprogram of the PL/SQL block.
Here the label declaration which contains the label_name encapsulated within the << >> symbol and must be followed by at least one statement to execute.
Syntax:
Here the label declaration which contains the label_name encapsulated within the << >> symbol and must be followed by at least one statement to execute.
Example of PL/SQL GOTO statement
Let’s take an example of PL/SQL GOTO statement.
After the execution of above code, you will get the following result:
value of a: 30 value of a: 31 value of a: 32 value of a: 33 value of a: 34 value of a: 36 value of a: 37 value of a: 38 value of a: 39 value of a: 40 value of a: 41 value of a: 42 value of a: 43 value of a: 44 value of a: 45 value of a: 46 value of a: 47 value of a: 48 value of a: 49 Statement processed.
Restriction on GOTO statement
Following is a list of some restrictions imposed on GOTO statement.
- Cannot transfer control into an IF statement, CASE statement, LOOP statement or sub-block.
- Cannot transfer control from one IF statement clause to another or from one CASE statement WHEN clause to another.
- Cannot transfer control from an outer block into a sub-block.
- Cannot transfer control out of a subprogram.
- Cannot transfer control into an exception handler.
Next TopicPL/SQL Procedure