X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 033BC11F6CB6 for ; Sat, 8 Apr 2006 18:46:29 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.131 X-Spam-Level: X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id hPonKeFJL8zS for ; Sat, 8 Apr 2006 18:46:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2FB2311F6CD7 for ; Sat, 8 Apr 2006 18:46:25 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k38LkQ9r028753; Sat, 8 Apr 2006 17:46:27 -0400 (EDT) To: "Keith Hutchison" cc: pgsql-sql@postgresql.org Subject: Re: Returning a set from an function In-reply-to: <45435c1a0604081410o12d5a456x1fb6d09ce8973cc6@mail.gmail.com> References: <45435c1a0604081410o12d5a456x1fb6d09ce8973cc6@mail.gmail.com> Comments: In-reply-to "Keith Hutchison" message dated "Sun, 09 Apr 2006 07:10:38 +1000" Date: Sat, 08 Apr 2006 17:46:26 -0400 Message-ID: <28752.1144532786@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200604/59 X-Sequence-Number: 24868 "Keith Hutchison" writes: > Looking for an example showing how to return a set from either a sql > function or a plpsqq function. Try "SQL Functions Returning Sets" here: http://www.postgresql.org/docs/8.1/static/xfunc-sql.html In plpgsql you just "RETURN NEXT" each value (typically this would be inside a loop, though it doesn't have to be) and then either RETURN with no argument or fall off the end of the function (I think the latter is only allowed as of PG 8.1). There don't seem to be any very compelling examples in the manual, but I bet you can find some at techdocs.postgresql.org. regards, tom lane