Search Postgresql Archives

Re: return setof : alternatives to holder table

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

 



On Sun, Aug 15, 2010 at 12:21 PM, zhong ming wu <mr.z.m.wu@xxxxxxxxx> wrote:
> On Sun, Aug 15, 2010 at 11:57 AM, Joe Conway <mail@xxxxxxxxxxxxx> wrote:
>> On 08/15/2010 07:57 AM, zhong ming wu wrote:
>>> Here is what I have tried
>>>
>>> create or replace function te(out a int,out b int) returns setof record as
>>> $pgsql$
>>> declare
>>> r record;
>>> begin
>>> r.a := 1;
>>> r.b := 2;
>>> return next;
>>> end;
>>> $pgsql$ language plpgsql;
>>
>> Try:
>>
>> create or replace function te(out a int,out b int)
>> returns setof record as $pgsql$
>>  begin
>>    a := 1;
>>    b := 2;
>>    return next;
>>  end;
>> $pgsql$ language plpgsql;
>>
>> contrib_regression=# select * from te();
>>  a | b
>> ---+---
>>  1 | 2
>> (1 row)
>>
>> -- or --
>>
>> create or replace function te()
>> returns TABLE(a int, b int) as $pgsql$
>>  begin
>>    a := 1;
>>    b := 2;
>>    return next;
>>  end;
>> $pgsql$ language plpgsql;
>>
>> contrib_regression=# select * from te();
>>  a | b
>> ---+---
>>  1 | 2
>> (1 row)
>>
>

The second example is perfect in that I just need to insert my table
definition into function definition.  Thanks.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[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