Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread zhong ming wu
On Sun, Aug 15, 2010 at 12:21 PM, zhong ming wu wrote: > On Sun, Aug 15, 2010 at 11:57 AM, Joe Conway 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 >>>

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread Joe Conway
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 functio

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread zhong ming wu
On Sun, Aug 15, 2010 at 6:18 AM, Mike Christensen wrote: > On Sun, Aug 15, 2010 at 3:10 AM, Craig Ringer > wrote: >> >> On 15/08/10 18:00, zhong ming wu wrote: >> >> > Thanks for any better solution to this >> >> CREATE TYPE >> >> However, you still have to have a special type around just for tha

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread Craig Ringer
On 15/08/2010 6:18 PM, Mike Christensen wrote: How about just using OUT parameters? CREATE FUNCTION FOO(IN _id uuid, OUT col1 text, OUT col2 text) RETURNS SETOF record AS BEGIN select col1, col2 from test where id=_id; END; Then your output just has to match the signature of

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread Mike Christensen
On Sun, Aug 15, 2010 at 3:10 AM, Craig Ringer wrote: > On 15/08/10 18:00, zhong ming wu wrote: > > > Thanks for any better solution to this > > CREATE TYPE > > However, you still have to have a special type around just for that > function, and you have to *maintain* it to ensure it always matches

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread A. Kretschmer
In response to zhong ming wu : > Hello List, > > I have a plpgsql function returning a set of records. The record is > effectively a join of some tables. > > For example, table a (column a1,column a2,column a3,column a4) > > table b(column b1,column b2,column b4) > > I am returning a set of (a

Re: [GENERAL] return setof : alternatives to holder table

2010-08-15 Thread Craig Ringer
On 15/08/10 18:00, zhong ming wu wrote: > Thanks for any better solution to this CREATE TYPE However, you still have to have a special type around just for that function, and you have to *maintain* it to ensure it always matches the types/columns of the input tables. I frequently wish for type

[GENERAL] return setof : alternatives to holder table

2010-08-15 Thread zhong ming wu
Hello List, I have a plpgsql function returning a set of records. The record is effectively a join of some tables. For example, table a (column a1,column a2,column a3,column a4) table b(column b1,column b2,column b4) I am returning a set of (a2,a4,b2). What I do now is to create a empty table