From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Amit Phatarphekar" <amit(at)visionaire-us(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Returning columns from different tables, in plpgsql function |
Date: | 2007-12-08 13:54:48 |
Message-ID: | b42b73150712080554w7c3bff6bj3dc4c966c3de13c1@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Dec 7, 2007 6:57 PM, Amit Phatarphekar <amit(at)visionaire-us(dot)com> wrote:
> Currently if I have to return columns from multiple tables, I have to define
> my own TYPE and then return SETOF that type in the function. I've provided
> an example below.
>
> Now, if I have to add a column to the select query, I have drop the existing
> TYPE definition, create a new TYPE with the new column added to it, and then
> modify the function sql to return this extra column.
>
> Question – Is there any other way to doing this? - Is everybody following
> the same approach out there? I know I can return a SETOF RECORD type and
> then define in the function call, all the columns that are being returned.
> But I like TYPE the definition approach better than this anyways. Let me
> know if I'm missing anything in the mix.
>
you can use (in 8.1+) out parameters and define the return type as
record. This is probably the best way in terms of management, unless
you want to return a type for other reasons.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Geoffrey | 2007-12-08 14:21:28 | Re: Slony replication |
Previous Message | Alain Roger | 2007-12-08 12:54:39 | Re: list of roles |