LOOP Usage Notes - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
  • You can qualify LOOP with a statement label.

    A LEAVE statement specified within the LOOP breaks the iteration statement, passing control to the next statement following the statement with that label.

  • You must specify a LEAVE statement inside the LOOP statement to make sure of normal termination of the statement.

    If you do not, the loop iterates continuously and can only be stopped by an asynchronous abort.

  • Causes of LOOP-Terminating Errors
    • If a statement in the LOOP raises an exception condition and a CONTINUE handler has been declared for that condition, then the stored procedure execution continues.
    • If an EXIT handler has been declared, then the statement terminates the stored procedure execution.
    • If a statement within the loop raises an error condition and its associated SQLSTATE code is not defined for a handler, then both the loop and the stored procedure terminate.