Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E11B2B5DBCA for ; Mon, 4 Jul 2011 10:41:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 59537-01 for ; Mon, 4 Jul 2011 13:41:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 66698B5D8C5 for ; Mon, 4 Jul 2011 10:41:26 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QdjOv-0007iv-E1 for pgsql-sql@postgresql.org; Mon, 04 Jul 2011 15:41:25 +0200 Received: from 212.126.222.122 ([212.126.222.122]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Jul 2011 15:41:25 +0200 Received: from hari.fuchs by 212.126.222.122 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Jul 2011 15:41:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Harald Fuchs Subject: Re: Usage of function retruning record in query Date: Mon, 04 Jul 2011 15:41:12 +0200 Lines: 14 Message-ID: <868vseduyv.fsf@mgm.protecting.net> References: <1309762075448-4549140.post@n5.nabble.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.126.222.122 X-Archive: encrypt User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:ChtAin1TJml7Pb9HvPuscj5y1nc= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.735 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_NUMERIC_HELO=1.164, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201107/2 X-Sequence-Number: 35572 In article <1309762075448-4549140.post@n5.nabble.com>, gmb writes: > Hi I have a stored function returning a record consisting of two field, > and receiving as input a single identifier: CREATE FUNCTION calcvalues(IN > itemid VACHAR, OUT calcval1 NUMERIC, OUT calcval2 NUMERIC) RETURNS > record... Now, I want to use this function in a query as follows: SELECT > itemid, calcvalues(itemid) FROM itemlist; which returns: itemid | > calcvalues --------+------------- 4 | (0.67,10.00) 5 | (1.55,45.00) 6 | > (3.60,69.00) Now, how should I go about to give the following output: > itemid | calcval1 | calcval2 --------+----------+---------- 4 | 0.67 | > 10.00 5 | 1.55 | 45.00 6 | 3.60 | 69.00 Any feedback will be appreciated. SELECT itemid, (calcvalues(itemid)).* FROM itemlist