From: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
---|---|
To: | Nigel Horne <njh(at)bandsman(dot)co(dot)uk> |
Cc: | "A(dot) Kretschmer" <akretschmer(at)despammed(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: |
Date: | 2005-08-22 14:47:40 |
Message-ID: | BF2F5DCC.CEE4%sdavis2@mail.nih.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 8/22/05 9:56 AM, "Nigel Horne" <njh(at)bandsman(dot)co(dot)uk> wrote:
> On Mon, 2005-08-22 at 14:49, Tino Wildenhain wrote:
>> Nigel Horne schrieb:
>>> On Fri, 2005-08-19 at 16:34, A. Kretschmer wrote:
>>>
>>>> am 19.08.2005, um 15:58:20 +0100 mailte Nigel Horne folgendes:
>>>>
>>>>> I can't work out from that how to return more than one value.
>>>>
>>>> 17:35 < rtfm_please> For information about srf
>>>> 17:35 < rtfm_please> see
>>>> http://techdocs.postgresql.org/guides/SetReturningFunctions
>>>> 17:35 < rtfm_please> or
>>>> http://www.postgresql.org/docs/current/static/xfunc-sql.html#AEN28835
>>>
>>>
>>> How does that help with my problem? I seems to discuss returning more
>>> than one row of a table which is not the question I asked.
>>>
>>
>> try to tell your questions more precisely :-)
>
> I want to return more than one value from a procedure, e.g. a string and
> an integer.
>
>> I think you want to return a record or tabletype.
>
> Not really, since those values could be computed on the fly, they may
> not be values in a database.
Actually, that is what you want. Here is a concrete example:
CREATE OR REPLACE FUNCTION test_return(int,int) RETURNS RECORD AS $$
DECLARE
a alias for $1;
b alias for $2;
ret record;
BEGIN
select into ret a, b, a+b;
RETURN ret;
END;
$$ language plpgsql;
select * from test_return(1,2) as t(a int, b int, s int);
a | b | s
---+---+---
1 | 2 | 3
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Clodoaldo Pinto | 2005-08-22 15:00:10 | Re: extract (dow/week from date) |
Previous Message | Adam Witney | 2005-08-22 14:37:38 | Re: |