LEAVE

Top  Previous  Next

Leave the current loop.

 

Syntax

<loop_statement>

BEGIN

  ...

  LEAVE;

  ...
END

 

Exit the current loop, execution will resume after the loop statement.

 

See Also

WHILE ... DO
REPEAT ... UNTIL
FOREACH
FOR SELECT
FOR EXECUTE STATEMENT

 

Example

EXECUTE UDSBLOCK (i integer)

AS

BEGIN

  WHILE (1 = 1)

  DO BEGIN

       IF (Math.Mod(i, 5) = 0) /* check to see if the number can be divided by 5, if so, leave the loop */

       THEN LEAVE;

       ELSE i = i + 1;

     END

  /* other stuff */

END

 

This loop will increase the input i-value as long as it cannot be divided by 5. If it can, it will lave the loop.