Home
END statements of labeled blocks should be labeled
Description
The "END statements of labeled blocks should be labeled" rule states that any END statement used to close a labeled block should be labeled with the same label used to open the block. This helps to ensure that the code is properly structured and that the programmer can easily identify the start and end of the labeled block. Labeling the END statement also helps to reduce the chances of errors in the code, as it makes it easier to identify the start and end of the block.
Key Benefits
- Easier to read and maintain code : Labeling the end of a block of code makes it easier to read and maintain, as it is clear where the block of code ends.
- Easier to debug code : Labeling the end of a block of code makes it easier to debug, as it is clear where the block of code ends.
- Easier to find errors : Labeling the end of a block of code makes it easier to find errors, as it is clear where the block of code ends.
Non-compliant Code Example
<<outerone>>
BEGIN
DECLARE
abc INTEGER;
BEGIN
IF abc = outerone.abc THEN -- refers to global abc
NULL;
END IF;
END;
END; --Non compliant code (END statements of labeled blocks is not labeled)
Compliant Code Example
<<outerone>>
BEGIN
DECLARE
abc INTEGER;
BEGIN
IF abc = outerone.abc THEN -- refers to global abc
NULL;
END IF;
END;
END outerone; --Compliant code (END statements of labeled blocks is labeled)