Navigation:  NexusDB Guide > SQL Reference > SQL Statements > Control Statements >

WHILE statement

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

WHILE statement

button_main button_prev button_next

NexusDB Manual V3 > SQL Reference > SQL Statements > Control Statements

Repeat the execution while the condition is true.

 

Syntax

 

<while statement> ::=

 

 

 

WHILE <search condition> DO

<SQL statement list>

END WHILE

 

Usage

 

The WHILE statement is used to specify a repeated iteration of the statement block while the search condition is true.

 

See also: REPEAT statement

 

 

Examples

 

1)

The following example shows the WHILE statement used in SQL code:

 

      DROP FUNCTION IF EXISTS dummyFunc;

      CREATE FUNCTION dummyFunc( p1 INTEGER )

      RETURNS INTEGER

      BEGIN

DECLARE v1, v2 INTEGER;

SET v1 = 10;

SET v2 = 10;

WHILE v1 > 0 DO

SET v1 = v1 - 1;

IF v1 <= 5 THEN

ITERATE;

END IF;

SET v2 = v2 - 1;

END WHILE;

RETURN v2 + p1;

      END;

      SELECT dummyFunc( 15 ) FROM #dummy;

 

 


Conformance

 

SQL:2003 standard

-

-

SQL/PSM Feature P002-12 "WHILE statement"

Beginning and ending statement labels are not supported

 

© Nexus Database Systems Pty Ltd.

nexus_logo