From: Tom Lane <tgl@sss.pgh.pa.us>
To: terence.kearns@canberra.edu.au
Cc: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: returning a recordset from PLpg/SQL
Date: Mon, 01 Mar 2004 12:10:15 -0500
Message-ID: <471.1078161015@sss.pgh.pa.us> (raw)
In-Reply-To: <20040301073006.A71391@megazone.bigpanda.com>
References: <4041DCBF.203@isd.canberra.edu.au>
<14883.1078067508@sss.pgh.pa.us>
<40435499.7050805@isd.canberra.edu.au>
<20040301073006.A71391@megazone.bigpanda.com>
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> On Tue, 2 Mar 2004, Terence Kearns wrote:
>> Well I haven't yet done anything because I couldn't get anything to
>> compile which returned SETOF RECORD..
> As a starting point, SETOF "RECORD" is different from SETOF RECORD given
> PostgreSQL's fold case to lower case for unquoted names.
Also, you can hardly expect a function to return a rowtype that doesn't
even exist until the function executes --- how the heck is the parser
supposed to make sense of the calling query? So the "execute create
type" part of this is nonsense, I'm afraid. The SETOF RECORD mechanism
will let you return a rowtype that is not known fully at the time the
function is written, but the rowtype does have to be known when the
calling query is parsed.
You might be able to replace the CREATE TYPE with an anonymous record
type in the calling query:
select ...
from details_for_profile(...) as x(doc_id int4,
doc_title varchar(256),
...);
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, terence.kearns@canberra.edu.au, sszabo@megazone.bigpanda.com
Subject: Re: returning a recordset from PLpg/SQL
In-Reply-To: <471.1078161015@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox