LOOP Statement

Repeats the execution of a statement list.

Syntax

statement-label: ]
... [ WHILE search-condition ] LOOP
... statement-list
... END LOOPstatement-label ]

Examples

Usage

The WHILE and LOOP statements are control statements that let you repeatedly execute a list of SQL statements while a search-condition evaluates to TRUE. The LEAVE statement can be used to resume execution at the first statement after the END LOOP.

If the ending statement-label is specified, it must match the beginning statement-label.

Standards

  • SQL—ISO/ANSI SQL compliant.

  • Sybase—Not supported in Adaptive Server Enterprise. The WHILE statement provides looping in Transact-SQL stored procedures.

Permissions

None

Related reference
FOR Statement
LEAVE Statement
WHILE Statement [T-SQL]