GOTO

Use the GOTO statement to transfer control of program execution to the statement that has a specified statement label.

Syntax


1  GOTO label  ;

Element Description Restrictions Syntax
label Name of the loop label for this loop Must be unique among labels in this SPL routine Identifier

Usage

The GOTO statement branches to a statement label unconditionally. The statement label must be unique within its scope and must precede an executable statement. When successfully executed, the GOTO statement transfers control to the labeled statement or statement block.

In the following program fragment, the jump_back function transfers control to a LET statement that has the statement label back if the value of variable j is greater than 100.
CREATE FUNCTION jump_back()
   RETURNING INT;
   DEFINE i,j INT;
   ...
   <<back>>
   LET j = j + i
   FOR i IN (1 TO 52 STEP 5)
      IF i < 11 THEN
         LET j = j + 3
         CONTINUE FOR;
      END IF;
      IF j > 100 THEN
         GOTO back
      END IF;
      RETURN j WITH RESUME;
   END FOR;
END FUNCTION;

The GOTO statement is not valid in an ON EXCEPTION statement block.

The identifier of the statement label that the GOTO statement references must exist in the database, must be unique among statement labels and loop labels the SPL routine, and must be within a scope that the GOTO statement can reach.

Related Statements

<< Label >> statement