【发布时间】:2014-05-06 12:11:24
【问题描述】:
如何将下面的查询映射到 postgres 函数。
WITH RECURSIVE source (counter, product) AS (
SELECT
1, 1
UNION ALL
SELECT
counter + 1, product * (counter + 1)
FROM source
WHERE
counter < 10
)
SELECT counter, product FROM source;
我是 postgres 的新手。我想使用 PL/pgsql 函数实现相同的功能。
【问题讨论】:
-
创建一个使用
return query的函数。请参阅手册中的示例:postgresql.org/docs/current/static/…
标签: postgresql plpgsql postgresql-9.2 recursive-query