小编fab*_*onr的帖子

Postgresql - 返回表的函数出错

我刚刚定义了这个函数来返回给定表中的所有列名:

create or replace function GET_COLUMNS(in tbl_name character varying(30))
returns table(colunas character varying) as $$
begin
    SELECT column_name
    FROM information_schema.columns
    WHERE table_schema = 'Main'
    AND table_name   = tbl_name;
end;
$$ language 'plpgsql'
Run Code Online (Sandbox Code Playgroud)

但是当我使用它调用它时,select * from get_columns('tabfuncionarios');我收到了以下错误:

ERROR:  query has no destination for result data
HINT:  If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT:  PL/pgSQL function get_columns(character varying) line 3 at SQL statement
Run Code Online (Sandbox Code Playgroud)

我正在使用postgresql 9.4.5版本

postgresql plpgsql

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

plpgsql ×1

postgresql ×1