X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA4A2D1B18F for ; Wed, 9 Jun 2004 05:58:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71995-04 for ; Wed, 9 Jun 2004 08:58:42 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 0F8B3D1B1B3 for ; Wed, 9 Jun 2004 05:58:39 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1BXyus-000N1M-0V; Wed, 09 Jun 2004 09:58:38 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id F196E16239; Wed, 9 Jun 2004 09:58:37 +0100 (BST) Message-ID: <40C6D140.8010701@archonet.com> Date: Wed, 09 Jun 2004 09:58:40 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.6 (X11/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: terence.kearns@canberra.edu.au Cc: pgsql-sql@postgresql.org Subject: Re: returning a recordset from PLpg/SQL References: <4041DCBF.203@isd.canberra.edu.au> In-Reply-To: <4041DCBF.203@isd.canberra.edu.au> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/69 X-Sequence-Number: 18014 Terence Kearns wrote: > Looking at the datatypes you can RETURN, it doesn't seem that there is a > way to return a recordset > > I tried > RETURNS SETOF RECORD > but that doesn't work > > I even tried > RETURNS SETOF fooTable%ROWTYPE > > What I would like to do is not that simple, I need to be able to > build/declare a record definition with an arbitary list of columns and > then return a set of that record which has it's values populated by > queries and calculations inside the procedure. Declare your datatype (CREATE TYPE ...) and return a SETOF that. What you can't do is declare your datatype inside your function. Clearly PostgreSQL needs to know what type is being returned while parsing the function, so you can't have a "dynamic type" (if such an idea has any meaning at all). -- Richard Huxton Archonet Ltd