Re: returning a recordset from PLpg/SQL - Mailing list pgsql-sql

From Tom Lane
Subject Re: returning a recordset from PLpg/SQL
Date
Msg-id 471.1078161015@sss.pgh.pa.us
Whole thread Raw
In response to Re: returning a recordset from PLpg/SQL  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: returning a recordset from PLpg/SQL
Re: returning a recordset from PLpg/SQL
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Dana Hudes
Date:
Subject: Re: User defined types -- Social Security number...
Next
From: Steve Crawford
Date:
Subject: Re: User defined types -- Social Security number...