How to use recursive clause in one with query

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to use recursive clause in one with query
Date: 2014-08-08 21:19:57
Message-ID: 768C1760D2C44B2DB58B96AE2262066C@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How to use one recursive query if there are may queries in WITH statement ?

I tried

with
a as ( select 1 as col1 ),
RECURSIVE t(n) AS (
VALUES (1)
UNION ALL
SELECT n+1 FROM t WHERE n < 100
),
c as (select * from t)
select * from c

but got error

syntax error at or near "t"

at line

RECURSIVE t(n) AS (

recursive b as ( shown in comment

with clause is used to create some non recursive queries (a) .
After them recursive query is defined (b) and after it there are some other non-recursive queries (c)

Using Postgres 9.1 and above.

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-08-08 21:36:11 Re: How to use recursive clause in one with query
Previous Message Tim Smith 2014-08-08 21:14:56 A question for Postgres OLAP gurus ....