Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 92AA3B5D91F for ; Mon, 4 Jul 2011 03:48:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97598-07 for ; Mon, 4 Jul 2011 06:47:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id 0FAD8B5D80A for ; Mon, 4 Jul 2011 03:47:55 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1Qdcwl-0002mT-Eh for pgsql-sql@postgresql.org; Sun, 03 Jul 2011 23:47:55 -0700 Date: Sun, 3 Jul 2011 23:47:55 -0700 (PDT) From: gmb To: pgsql-sql@postgresql.org Message-ID: <1309762075448-4549140.post@n5.nabble.com> Subject: Usage of function retruning record in query MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_601_9792886.1309762075450" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.766 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201107/1 X-Sequence-Number: 35571 ------=_Part_601_9792886.1309762075450 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Usage-of-function-retruning-record-in-query-tp4549140p4549140.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. ------=_Part_601_9792886.1309762075450 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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.

View this message in context: Usage of function retruning record in query
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
------=_Part_601_9792886.1309762075450--