X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 81D34D1E2BE for ; Mon, 1 Mar 2004 17:10:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 03257-08 for ; Mon, 1 Mar 2004 13:10:30 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 45F07D1DF92 for ; Mon, 1 Mar 2004 13:10:29 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i21HAFUT000472; Mon, 1 Mar 2004 12:10:15 -0500 (EST) To: terence.kearns@canberra.edu.au Cc: Stephan Szabo , pgsql-sql@postgresql.org Subject: Re: returning a recordset from PLpg/SQL 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> Comments: In-reply-to Stephan Szabo message dated "Mon, 01 Mar 2004 07:31:24 -0800" Date: Mon, 01 Mar 2004 12:10:15 -0500 Message-ID: <471.1078161015@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/6 X-Sequence-Number: 17105 Stephan Szabo 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