Reputation: 21817
I have PostgreSQL table. I need in function which returns setof varchar
. My table:
create table my_table (
str varchar not null
)
How can I write a function that returns a set of str
field?
Upvotes: 0
Views: 1001
Reputation: 656636
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.
Upvotes: 1