PLSQL - variable at the end of the Loop Statement

Viewed 33

I was reviewing a colleague's code and found something similar below:

begin
    for i in (select 'x' from dual) loop
        null;
    end loop Y; 
end;

I can't understand why this compiles and runs. Shouldn't it fail because of the "Y" variable? I tried other variables as well but it compiles.

please advise.

Thank you.

1 Answers

These are just statement labels and exist to name a particular part of the program, it's not much different from the label you put after the begin end of a procedure to mark the end of the procedure.

For reference

Related