Re: http://www.postgresql.org/docs/8.0/static/xfunc-sql.html

From: Adam Witney <awitney(at)sgul(dot)ac(dot)uk>
To: Nigel Horne <njh(at)bandsman(dot)co(dot)uk>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: http://www.postgresql.org/docs/8.0/static/xfunc-sql.html
Date: 2005-08-19 15:30:21
Message-ID: BF2BB99D.4B1EB%awitney@sgul.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I can't work out from that how to return more than one value.

Hi Nigel,

Add SETOF to your function like so:

CREATE TABLE test (id int);
INSERT INTO test VALUES(1);
INSERT INTO test VALUES(2);

CREATE FUNCTION test_func() RETURNS SETOF integer AS '
SELECT id FROM test;
' LANGUAGE SQL;

SELECT test_func();

Cheers

Adam

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

In response to

Responses

  • Re: at 2005-08-19 15:36:26 from Nigel Horne
  • Re: at 2005-08-19 15:38:20 from Nigel Horne

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2005-08-19 15:30:25 Re: Stored functions
Previous Message Alvaro Herrera 2005-08-19 15:22:04 Re: total db lockup