iteration_statement - Analytics Database - Teradata Vantage

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

A WHILE, LOOP, FOR, or REPEAT statement.

See Teradata Vantage™ - SQL Stored Procedures and Embedded SQL, B035-1148 for details.

You can specify these options for iteration statements.

WHILE
Keyword introducing an iteration statement to repeat the execution of one or more statements within its defined scope.
The associated condition is checked before each iteration (including the first) and if true, the statements are performed. Otherwise, the WHILE statement completes with no further iterations.
See Teradata Vantage™ - SQL Stored Procedures and Embedded SQL, B035-1148 for details.
DO
Keyword introducing the sequence of statements to be performed in the WHILE statement.
END WHILE
Keywords indicating the ending of the sequence of statements in the WHILE statement.
LOOP
Keyword introducing an iteration statement that repeats the execution of one or more statements embedded within the defined loop.
END LOOP
Keywords that terminate a LOOP.
FOR
Keyword introducing an iteration statement to repeat the execution of one or more statements for each row fetched by the cursor.
for_loop_variable
Name of the FOR loop.
See Teradata Vantage™ - SQL Fundamentals, B035-1141 for the rules for naming database objects.
cursor_name
Name of the cursor.
The maximum length of a database object name is either 30 LATIN characters or 128 Unicode characters. For details about object name length limits, see Teradata Vantage™ - SQL Fundamentals, B035-1141.
CURSOR FOR
Optional keywords qualifying the cursor_name as the cursor for the statement set to follow.
cursor_specification
The SELECT statement specifying the column names or expressions from which to fetch data rows in the CURSOR statement.
DO
Keyword introducing the sequence of statements to be performed in the CURSOR statement.
END FOR
Keywords ending the CURSOR statement.
REPEAT
Keyword introducing the iteration statement that repeats the execution of one or more statements within the defined REPEAT statement.
UNTIL
Keyword introducing a conditional expression to qualify the statements in the loop.
END REPEAT
Keywords ending the REPEAT statement.