leave

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

leave [2015/09/23 20:27] (current)
Line 1: Line 1:
 +====== LEAVE Statement - PL/HQL Reference ======
 +
 +LEAVE statement exits the loop or block marked by the given label. If the label is not specified, LEAVE exists ​ the innermost loop. 
 +
 +**Syntax:**
 +
 +<code language=sql>​
 +LEAVE [label];
 +</​code>​
 +
 +**Example:​**
 +
 +<code language=sql>​
 +lbl:
 +WHILE count > 0 DO
 +  SET count = count - 1;
 +  IF count = 0 THEN
 +    LEAVE lbl;
 +  END IF;
 +END WHILE;
 +</​code>​
 +
 +<code language=sql>​
 +lbl:
 +WHILE 1=1 DO
 +  lbl1:
 +  WHILE 1=1 DO
 +    LEAVE lbl;
 +  END WHILE;
 +END WHILE;
 +</​code>​
 +
 +**Compatibility:​** Teradata, IBM DB2 and MySQL.