Re: Functions returning setof record -- can I use a table type as my return type hint?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: George MacKerron <g(dot)j(dot)mackerron(at)lse(dot)ac(dot)uk>
Cc: rod(at)iol(dot)ie, pgsql-general(at)postgresql(dot)org
Subject: Re: Functions returning setof record -- can I use a table type as my return type hint?
Date: 2011-08-12 16:43:20
Message-ID: CAHyXU0z8B9OQsV4M+Si4Cjnd9s4TTGwwjQw+9Oas8_WrUXHozw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 12, 2011 at 11:26 AM, George MacKerron
<g(dot)j(dot)mackerron(at)lse(dot)ac(dot)uk> wrote:
> Many thanks for the reply, Ray.
>
> Unfortunately, I don't think this addresses the problem, because I'd hoped not to have to hard-code the table name into the function.
>
> The point of the function is that you can pass it any table name (along with some other parameters) and it returns rows from that named table.

you can't have it both ways. at the time the function call is
executed, the return type/fields must be known. you can do this by
either a. explicitly defining the function return type or b.
describing the function return type in the function call, or c. use a
generic type to hold the output record structure which can be
parsed/dealt with later, like text or hstore.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2011-08-12 16:44:00 Re: Functions returning setof record -- can I use a table type as my return type hint?
Previous Message Rich Shepard 2011-08-12 16:37:21 Re: COPY from .csv File and Remove Duplicates