Icon LEAVE

Exits a block of statements.

Syntax
LEAVE [<Label>]

Usage
Use this statement to exit a block of statements contained within a BEGIN..END block or LOOP, REPEAT, or WHILE loop.

Examples
-- This function simply repeats a
-- a string the specified number of times
-- and returns the resultant string

CREATE FUNCTION RepeatString(IN "StringToRepeat" VARCHAR, IN "RepeatCount" INTEGER)
RETURNS VARCHAR
BEGIN
   DECLARE I INTEGER DEFAULT 1;
   DECLARE Result VARCHAR DEFAULT '';

   IF RepeatCount = 0 THEN
      LEAVE;
   END IF;
   
   REPEAT
      SET Result = (Result + StringToRepeat);
      SET I = (I + 1);
   UNTIL (I > RepeatCount) END REPEAT;

   RETURN Result;
END

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
Optional LabelThe label is optional in ElevateDB, and if not provided, defaults to the current block being executed.
Image