Re: Returning columns from different tables, in plpgsql function - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Returning columns from different tables, in plpgsql function
Date
Msg-id b42b73150712080554w7c3bff6bj3dc4c966c3de13c1@mail.gmail.com
Whole thread Raw
In response to Returning columns from different tables, in plpgsql function  ("Amit Phatarphekar" <amit@visionaire-us.com>)
List pgsql-general
On Dec 7, 2007 6:57 PM, Amit Phatarphekar <amit@visionaire-us.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

pgsql-general by date:

Previous
From: "Alain Roger"
Date:
Subject: Re: list of roles
Next
From: Geoffrey
Date:
Subject: Re: Slony replication