0

我有 PostgreSQL 表。我需要在返回的函数中setof varchar。我的桌子:

create table my_table (
    str varchar not null
)

如何编写返回一组str字段的函数?

4

1 回答 1

1

Basic example with LANGUAGE SQL:

CREATE OR REPLACE FUNCTION foo()
  RETURNS SETOF varchar
  LANGUAGE SQL AS
$BODY$
    SELECT str
    FROM   my_table
    WHERE  <some condition>;
$BODY$;

Call:

SELECT * FROM foo();

Start by reading the basics in the manual.

于 2012-06-06T14:57:24.910 回答