Search Postgresql Archives

Re:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/22/05 9:56 AM, "Nigel Horne" <njh@xxxxxxxxxxxxxx> 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)



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux