Home
Block labels should appear on the same lines as END
Description
The rule "Block labels should appear on the same lines as END" states that when writing PL/SQL code, the label of a block should be placed on the same line as the END statement that marks the end of the block. This helps to make the code more readable and easier to understand. It also makes it easier to identify the start and end of each block, which can be useful when debugging or troubleshooting.
Key Benefits
- Easier to read: Block labels should appear on the same lines as END, making code easier to read and understand.
- Fewer errors: By keeping block labels on the same lines as END, it reduces the chances of errors due to incorrect indentation.
- Better organization: Keeping block labels on the same lines as END helps to organize code better, making it easier to find and debug.
Non-compliant Code Example
<<outerloop>>
DECLARE
abc INTEGER;
BEGIN
DECLARE
abc INTEGER;
BEGIN
IF abc = outerloop.abc THEN -- refers to global abc
NULL;
END IF;
END;
END
outerloop; --Non compliant code (Block label is not placed in the same line as END)
Compliant Code Example
<<outerloop>>
DECLARE
abc INTEGER;
BEGIN
DECLARE
abc INTEGER;
BEGIN
IF abc = outerloop.abc THEN -- refers to global abc
NULL;
END IF;
END;
END outerloop; --Compliant code (Block label is placed in the same line as END)