Example: Simple REPLACE RECURSIVE VIEW - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The following example replaces the existing definition for the recursive view named rec with the specified SQL code:

    REPLACE RECURSIVE VIEW rec(p, mycount) AS (
      SELECT n, 0 AS mycount
      FROM t
      WHERE n = 1
    UNION ALL
      SELECT rec.p, rec.mycount + 1
      FROM t, rec
      WHERE rec.p = t.n
      AND   rec.mycount <= 20