On Sun, Aug 15, 2010 at 12:21 PM, zhong ming wu <mr.z.m.wu@gmail.com> wrote:
> On Sun, Aug 15, 2010 at 11:57 AM, Joe Conway <mail@joeconway.com> 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.