LOOP Statement

Repeats the execution of a statement list.

Quick Links:

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

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

Examples

(back to top)

Usage

(back to top)

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

(back to top)

  • SQL—ISO/ANSI SQL compliant.
  • SAP Sybase Database product—Not supported in Adaptive Server. The WHILE statement provides looping in Transact-SQL stored procedures.

Permissions

(back to top)

None

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