
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
64 lines
897 B
Plaintext
64 lines
897 B
Plaintext
== Why is this an issue?
|
|
|
|
The ``++EXIT WHEN++`` syntax can exit a loop depending on a condition. It should be preferred to the more verbose and error-prone ``++IF ... THEN EXIT; END IF;++`` syntax.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,sql]
|
|
----
|
|
SET SERVEROUTPUT ON
|
|
|
|
DECLARE
|
|
i PLS_INTEGER;
|
|
BEGIN
|
|
|
|
i := 0;
|
|
LOOP
|
|
IF i > 10 THEN -- Noncompliant
|
|
EXIT;
|
|
END IF;
|
|
|
|
DBMS_OUTPUT.PUT_LINE('i = ' || i);
|
|
i := i + 1;
|
|
END LOOP;
|
|
|
|
END;
|
|
/
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,sql]
|
|
----
|
|
SET SERVEROUTPUT ON
|
|
|
|
DECLARE
|
|
i PLS_INTEGER;
|
|
BEGIN
|
|
|
|
i := 0;
|
|
LOOP
|
|
EXIT WHEN i > 10;
|
|
|
|
DBMS_OUTPUT.PUT_LINE('i = ' || i);
|
|
i := i + 1;
|
|
END LOOP;
|
|
END;
|
|
/
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
This "IF...THEN...EXIT" should be replaced by "EXIT WHEN" statement.
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|