Re: returning a recordset from PLpg/SQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: terence(dot)kearns(at)canberra(dot)edu(dot)au
Cc: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: returning a recordset from PLpg/SQL
Date: 2004-03-01 17:10:15
Message-ID: 471.1078161015@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2004-03-01 17:42:48 Re: User defined types -- Social Security number...
Previous Message Dana Hudes 2004-03-01 16:54:01 Re: User defined types -- Social Security number...