Search Postgresql Archives

Re: return setof : alternatives to holder table

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

 



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)



HTH,

Joe

-- 
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support

Attachment: signature.asc
Description: OpenPGP digital signature


[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