我想创建一个plpgsql函数,它将执行一个简单的选择查询,即 . “从表名中选择*” . 当我通过此查询运行该函数时,就像“select function()”一样,它将输出为“Select * from table name” .
不需要PL / pgSQL功能 . 一个简单的SQL函数将:
create or replace function get_result() returns setof table_name as $$ select * from table_name; $$ language sql;
但是你需要使用 select * from function(); 来获得结果 not select function() ,因为set returns函数只能在 from 子句中使用 .
select * from function();
select function()
from
1 回答
不需要PL / pgSQL功能 . 一个简单的SQL函数将:
但是你需要使用
select * from function();
来获得结果 notselect function()
,因为set returns函数只能在from
子句中使用 .