Details

    • Type: Language-Specification
    • Status: Active
    • Resolution: Unresolved
    • Labels:
      None
    • Impact:
      Unknown 'null' severity
    • Likelihood:
      Unknown 'null' severity
    • Legacy Key:
      PlSql.Goto
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2h

      Description

      A GOTO statement is an unstructured change in the control flow. They should be avoided and replaced by structured constructs.

      Noncompliant Code Example

      SET SERVEROUTPUT ON
      
      DECLARE
        i PLS_INTEGER := 42;
      BEGIN
        IF i < 0 THEN
          GOTO negative; -- Noncompliant
        END IF;
      
        DBMS_OUTPUT.PUT_LINE('positive');
        goto cleanup; -- Noncompliant
      
        <<negative>>
        DBMS_OUTPUT.PUT_LINE('negative!');
      
        <<cleanup>>
        NULL;
      END;
      /
      

      Compliant Solution

      SET SERVEROUTPUT ON
      
      DECLARE
        i PLS_INTEGER := 42;
      BEGIN
        IF i < 0 THEN
          DBMS_OUTPUT.PUT_LINE('negative!'); -- Compliant
        ELSE
          DBMS_OUTPUT.PUT_LINE('positive');
        END IF;
      END;
      /
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ann.campbell.2 Ann Campbell
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: