Home

GOTO statements should not be used

Rule description

  • GOTO statements should not be used

 

Non-compliant Code Example

DECLARE @Counter int;  
SET @Counter = 1;  
WHILE @Counter < 10  
    BEGIN   
        SELECT @Counter  
        SET @Counter = @Counter + 1  
        IF @Counter = 4 GOTO Branch_One  --Non compliant code (GOTO statements is used)
        IF @Counter = 5 GOTO Branch_Two   --Non compliant code (GOTO statements is used)
    END  
Branch_One:  
    SELECT 'Jumping To Branch One.'  
    GOTO Branch_Three;  --Non compliant code (GOTO statements is used)
Branch_Two:  
    SELECT 'Jumping To Branch Two.'  
Branch_Three:  
    SELECT 'Jumping To Branch Three.'; 
Visual Expert 2020
 VETSQLRULE23