Block start and end labels should match
The rule "Block start and end labels should match" states that when writing PL/SQL code, the labels used to mark the start and end of a block of code should be the same. This helps ensure that the code is properly structured and that all of the code within a block is executed as expected. It also helps to make the code easier to read and understand.
- Prevent Syntax Errors: Blocks of code start and end labels must match in order to prevent syntax errors.
- Improve Code Readability: The matching labels make it easier to read the code and understand the logic.
- Enforce Structured Programming: The matching labels help to enforce structured programming.
Non-compliant Code Example
<<outerone>> --Non compliant code (Block start and end label are not matching) BEGIN DECLARE abc INTEGER; BEGIN IF abc = outerone.abc THEN -- refers to global abc NULL; END IF; END; END innerone;
Compliant Code Example
<<outerone>> --Compliant code (Block start and end labels are same) BEGIN DECLARE abc INTEGER; BEGIN IF abc = outerone.abc THEN -- refers to global abc NULL; END IF; END; END outerone;