Labeled blocks are useful to help maintainers match-up the beginning and ending of each section of code, especially when that code is badly indented. However, if used, those labels must appear on the same line as the "END" keyword in order to avoid confusion. Otherwise, the label might be misread by maintainers as a procedure call.


== Noncompliant Code Example

----
SET SERVEROUTPUT ON

DECLARE
  PROCEDURE foo AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('foo was called!');
  END;
BEGIN
  BEGIN
    NULL;
  END -- Semicolon was forgotten?

  foo; -- Noncompliant; looks like a procedure call, but is actually END block label

  <<myBlockLabel>>
  BEGIN
    NULL;
  END 
  myBlockLabel; -- Noncompliant
END;
/
----


== Compliant Solution

----
SET SERVEROUTPUT ON

DECLARE
  PROCEDURE foo AS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('foo was called!');
  END;
BEGIN
  BEGIN
    NULL;
  END; 

  foo; -- The method "foo" was actually meant to be called

  <<myBlockLabel>>
  BEGIN
    NULL;
  END myBlockLabel;
END;
/
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
