Re: return setof : alternatives to holder table - Mailing list pgsql-general

From A. Kretschmer
Subject Re: return setof : alternatives to holder table
Date
Msg-id 20100815102002.GA31040@a-kretschmer.de
Whole thread Raw
In response to return setof : alternatives to holder table  (zhong ming wu <mr.z.m.wu@gmail.com>)
List pgsql-general
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 (a2,a4,b2). What I do now is to create a empty table
>
> foo(column a2,column a4,column b2)
>
> then in my function I have
>
> record r foo%rowtype
>
> I'm not happy with this solution because this foo tables has to be kept around
>
> Thanks for any better solution to this

You can create a aown typ or you can use IN/OUT-Parameters. I'm
prefering IN/OUT-Parameters, see here:

http://www.postgresonline.com/journal/archives/129-Use-of-OUT-and-INOUT-Parameters.html
http://bytes.com/topic/postgresql/answers/674690-output-parameters-functions


Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: return setof : alternatives to holder table
Next
From: Mike Christensen
Date:
Subject: Re: return setof : alternatives to holder table