Re: [sqlite] Recursive references in subqueries

2018-07-23 Thread John G
Just to nitpick : SQLite version 3.16.0 2016-11-04 19:09:39 Enter ".help" for usage hints. Connected to a transient in-memory database. sqlite> with recursive count_down(v) as ( ...> select 5 ...> union all ...> select n - 1 from count_down where n > 0 ...> ) ...>

Re: [sqlite] Recursive references in subqueries

2018-07-20 Thread Christian Duta
R Smith-2 wrote > The query above is perfectly defined. In fact, it works in PostgreSQL. > PostgreSQL's manual also has a very nice explanation of how recursive > queries are evaluated. The way PostgreSQL handles recursive queries was one of my motivations to post about this. PostgreSQL allows

Re: [sqlite] Recursive references in subqueries

2018-07-20 Thread Christian Duta
R Smith-2 wrote > The query above is perfectly defined. In fact, it works in PostgreSQL. > PostgreSQL's manual also has a very nice explanation of how recursive > queries are evaluated. The way PostgreSQL handles recursive queries was one of my motivations to post about this. PostgreSQL allows

Re: [sqlite] Recursive references in subqueries

2018-07-20 Thread R Smith
On 2018/07/19 10:23 PM, Lifepillar wrote: On 19/07/2018 15:53, R Smith wrote: In your example above, the full recursive set is not known at the time of first encountering the sub-query. i.e. do you expect it to have results on the first iteration? The query above is perfectly defined. In

Re: [sqlite] Recursive references in subqueries

2018-07-19 Thread Lifepillar
On 19/07/2018 15:53, R Smith wrote: On 2018/07/19 2:32 PM, Christian Duta wrote: WITH RECURSIVE   count_down(v) AS (     SELECT 5   UNION ALL     SELECT cd.v - 1     FROM (   SELECT cd.v   FROM count_down AS cd     ) AS cd     WHERE cd.v > 0   ) SELECT * FROM count_down; Error:

Re: [sqlite] Recursive references in subqueries

2018-07-19 Thread R Smith
On 2018/07/19 2:32 PM, Christian Duta wrote: WITH RECURSIVE   count_down(v) AS (     SELECT 5   UNION ALL     SELECT cd.v - 1     FROM (   SELECT cd.v   FROM count_down AS cd     ) AS cd     WHERE cd.v > 0   ) SELECT * FROM count_down; Error: near line 1: recursive reference in a

[sqlite] Recursive references in subqueries

2018-07-19 Thread Christian Duta
Hello, when writing a recursive queries, I encountered the following error: [...] recursive reference in a subquery: [...] The following minimal example illustrates when this error occurs: WITH RECURSIVE count_down(v) AS ( SELECT 5 UNION ALL SELECT cd.v - 1 FROM (