PostgreSQL:如何使用PostgreSQL在函数中返回SELECT语句的结果?
这里我有以下函数,但没有得到如何返回结果PostgreSQL:如何使用PostgreSQL在函数中返回SELECT语句的结果?,postgresql,Postgresql,这里我有以下函数,但没有得到如何返回结果 create or replace function f1() returns void as $body$ begin SELECT "Fname", "Lname", count("City" = 'A-B' OR NULL) AS "A-B", count("City" = 'C-D' OR NULL) AS "C-D", FROM "Table1"
create or replace function f1() returns void as
$body$
begin
SELECT "Fname",
"Lname",
count("City" = 'A-B' OR NULL) AS "A-B",
count("City" = 'C-D' OR NULL) AS "C-D",
FROM "Table1"
WHERE "City" in ('A-B','C-D')
GROUP BY 1,2
ORDER BY 1,2
将返回类型更改为
返回表(字段名类型,字段名类型,…)
并使用返回查询选择…
请参阅。当您想从函数中得到一些结果时,您的函数不能是无效函数。谢谢。但是结果显示在一列中。@user3382347胡乱猜测:您使用的是
SELECT my_procedure()
而不是SELECT*FROM my_procedure()
。非常感谢您,我收到了。