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 (http://www.postgresql.org/docs/8.4/static/queries-with.html
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;