| Sort Order | Loop Name | X |
| 1 | A | 1 |
| 2 | B | 101 |
| 3 | A | 2 |
| 4 | B | 101 |
Loop labels can come in handy, but it turns out you can put them in the wrong place and still get valid pl/sql code.
In this example, the closing label of loop_b has a "typo" and the closing label of loop_a should have been "loop_a", not "loop_b". I would expect both of these lines to result in a compilation error, but they don't.
The
Oracle documentation states:
"Labels improve readability, especially when LOOP statements are nested, but only if you ensure that the label in the END LOOP statement matches a label at the beginning of the same LOOP statement (the compiler does not check)."
So it works as advertised, but it did catch me by surprise.
Note that the exit statement also still works OK, so the end labels are indeed simply ignored.