Search Postgresql Archives

Re: Returning columns from different tables, in plpgsql function

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

 



On Dec 7, 2007 6:57 PM, Amit Phatarphekar <amit@xxxxxxxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster


[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