while

Differences

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

Link to this comparison view

while [2015/09/23 20:27] (current)
Line 1: Line 1:
 +====== WHILE Statement - PL/HQL Reference ======
 +
 +WHILE statement executes one or more statements while the condition is true. 
 +
 +Syntax:
 +
 +<code language=sql>​
 +[<<​label>>​ | label:]
 +WHILE boolean_expression LOOP | DO | BEGIN
 +  statements
 +END [LOOP | WHILE;]
 +</​code>​
 +
 +**Examples:​**
 +
 +<code language=sql>​
 +-- Oracle, PostgreSQL, Netezza
 +WHILE count > 0 LOOP
 +  count := count - 1;
 +END LOOP;
 +</​code>​
 +
 +<code language=sql>​
 +-- DB2, Teradata, MySQL
 +WHILE count > 0 DO
 +  SET count = count - 1;
 +END WHILE;
 +</​code>​
 +
 +<code language=sql>​
 +-- SQL Server
 +WHILE count > 0 BEGIN
 +  SET count = count - 1;
 +END
 +</​code>​
 +
 +**Compatibility:​** Oracle, Teradata, IBM DB2, Microsoft SQL Server, MySQL, PostgreSQL and Netezza.
 +
 +