WebSphere Message Broker, Version 8.0.0.7 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

LEAVE statement

The LEAVE statement stops the current iteration of the containing WHILE, REPEAT, LOOP, or BEGIN statement identified by Label.

The containing statement's evaluation of its loop condition (if any) is bypassed and looping stops.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-LEAVE--Label------------------------------------------------><

Examples

In the following example, the loop iterates four times:
DECLARE i INTEGER;
SET i = 1;
X : REPEAT 
  ...
  IF i>= 4 THEN
    LEAVE X;
  END IF;

  SET i = i + 1;
UNTIL
  FALSE
END REPEAT;
LEAVE statements do not have to be directly contained by their labelled statement, making LEAVE statements particularly powerful.
DECLARE i INTEGER;
SET i = 0;
X : REPEAT                   -- Outer loop
  ...
  DECLARE j INTEGER;
  SET j = 0;
  REPEAT                     -- Inner loop
    ...
    IF i>= 2 AND j = 1 THEN
      LEAVE X;               -- Outer loop left from within inner loop
    END IF;
    ...
    SET j = j + 1;
  UNTIL
    j>= 3
  END REPEAT;

  SET i = i + 1;
UNTIL
  i>= 3
END REPEAT X;
                             -- Execution resumes here after the leave
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2016Copyright IBM Corporation 1999, 2016.

        
        Last updated:
        
        Last updated: 2016-05-23 14:47:11


Reference topicReference topic | Version 8.0.0.7 | ak05070_