SQL for Reality > SQL Stored Procedures > WHILE Statement

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

Reality V15.0 ()

WHILE Statement (SQL) (m691509+while.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

WHILE Statement

Allows SQL statements to be repeated.

Syntax

WHILE condition statement

Syntax Elements

condition
An SQL Search Condition.

statement
A supported SQL statement, or a group of statements enclosed in the BEGIN and END keywords.

Operation

While condition evaluates to true, the WHILE statement executes statement repeatedly.

Example

SET @I = 0
SET @V1 = SECOND(CURTIME())+1
WHILE @I<10
BEGIN
SET @I = @I+1
SET @V2 = @V1*@I + @V1/@I
INSERT INTO TESTDATA VALUES(@I,@V2)
END

Loops, executing the block of three statements for each value of variable @I. The loop terminates when @I becomes equal to 10.

See Also

BREAK statement, CONTINUE statement.

RealityV15.0Comment on this topic