Re: RECURSIVE allowed only ONCE in a CTE

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Jitendra Loyal <jitendra(dot)loyal(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: RECURSIVE allowed only ONCE in a CTE
Date: 2019-02-22 10:06:06
Message-ID: 87pnrkgmxe.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Jitendra" == Jitendra Loyal <jitendra(dot)loyal(at)gmail(dot)com> writes:

Jitendra> I find that the RECURSIVE can be used only once in a CTE.

RECURSIVE can be specified only once, but it applies to all CTEs at that
level. That is to say, RECURSIVE qualifies the preceding WITH, _not_ the
following CTE.

Note that just specifying RECURSIVE doesn't mean that any CTE is
recursive, it simply changes the name scoping rules such that CTEs _can_
be recursive. (Without it, a CTE's name is not in scope in its own body
so recursion is impossible.)

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jitendra Loyal 2019-02-22 10:23:01 Re: RECURSIVE allowed only ONCE in a CTE
Previous Message Jitendra Loyal 2019-02-22 07:53:11 RECURSIVE allowed only ONCE in a CTE