iteration_statement - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
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.