[postmodern-devel] Anyone tried to use the new recursive with in Postgresql 8.4 with S-SQL?

Marijn Haverbeke marijnh at gmail.com
Mon Oct 5 17:40:40 UTC 2009


Hi Sabra,

WITH isn't a regular operator -- it has custom syntax, and as such
would require a custom s-sql operator. See s-sql/s-sql.lisp, it
shouldn't be too hard, looking at the :function operator, to build a
def-sql-op form for :with. If you get something working, I'd be happy
to add it to the distribution.

Best,
Marijn


On Thu, Oct 1, 2009 at 6:21 AM, Sabra Crolleton
<sabra.crolleton at gmail.com> wrote:
> I can't seem to get the syntax right using s-sql. I can write a straight sql
> statement, but it looks ugly in the middle of a lisp program.
>
> Sample sql statement from the postgresql docs is:
>
> WITH RECURSIVE search_graph(id, link, data, depth, path, cycle) AS (
>         SELECT g.id, g.link, g.data, 1,
>           ARRAY[g.id],
>           false
>         FROM graph g
>
>       UNION ALL
>         SELECT g.id, g.link, g.data, sg.depth + 1,
>           path || g.id,
>           g.id = ANY(path)
>         FROM graph g, search_graph sg
>
>         WHERE g.id = sg.link AND NOT cycle
> )
> SELECT * FROM search_graph;
>
> http://www.postgresql.org/docs/8.4/static/queries-with.html
>
> Sabra
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
>




More information about the postmodern-devel mailing list