Thread: Re: About Types

Re: About Types

From
mmiranda@americatel.com.sv
Date:
pgsql-general-owner@postgresql.org wrote:
> Hi everybody,
>
> I'm a PG newbie, and I'm trying to write a function that returns a
> set of records.
> These records come from 2 or more tables (joined).
>
> When I have only 1 table, the return type of the function can be SETOF
> mytable.
> When I have 2 tables or more, am I obliged to create a type (CREATE
> TYPE) so that my function can return a SETOF mytype?
>
> This works fine, but I'm trying to avoid building a specific type for
> each row returning function.
> Is there any other solution (SQL or PLPGSQL)?

Yes, return setof record, look at this site, it helped me  a lot.

http://techdocs.postgresql.org/guides/SetReturningFunctions

---
Miguel

Re: About Types

From
Hervé Inisan
Date:
> > This works fine, but I'm trying to avoid building a
> specific type for
> > each row returning function.
> > Is there any other solution (SQL or PLPGSQL)?
>
> Yes, return setof record, look at this site, it helped me  a lot.
>
> http://techdocs.postgresql.org/guides/SetReturningFunctions
>

Thank you Miguel and Otto.
RECORD did the trick :-)

-- Hervé Inisan.