48 lines
912 B
Plaintext
48 lines
912 B
Plaintext
Labeled loops are useful, especially when the code is badly indented, to match the begin and end of each loop. Within a labeled loop, the code's maintainability is increased by explicitly providing the loop's label in every ``++EXIT++`` statement. Indeed, if a nested loop is added afterwards, it is clear which loop has to be exited.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,sql]
|
|
----
|
|
BEGIN
|
|
<<myLoopLabel1>>
|
|
LOOP
|
|
EXIT; -- Noncompliant, the loop label is missing
|
|
END LOOP myLoopLabel1;
|
|
|
|
LOOP
|
|
EXIT; -- Compliant, this EXIT is not in a labeled loop
|
|
END LOOP;
|
|
END;
|
|
/
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,sql]
|
|
----
|
|
BEGIN
|
|
<<myLoopLabel1>>
|
|
LOOP
|
|
EXIT myLoopLabel1;
|
|
END LOOP myLoopLabel1;
|
|
|
|
LOOP
|
|
EXIT;
|
|
END LOOP;
|
|
END;
|
|
/
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|