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 50523529AF for ; Fri, 22 Jul 2005 13:57:01 -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 51169-02 for ; Fri, 22 Jul 2005 16:56:48 +0000 (GMT) Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net [216.204.66.226]) by svr1.postgresql.org (Postfix) with ESMTP id 1CB8752997 for ; Fri, 22 Jul 2005 13:56:44 -0300 (ADT) Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id j6MGuFk1027523; Fri, 22 Jul 2005 12:56:15 -0400 From: "Jim Buttafuoco" To: "Mark R. Dingee" , pgsql-sql@postgresql.org Reply-To: jim@contactbda.com Subject: Re: Multi-column returns from pgsql Date: Fri, 22 Jul 2005 12:56:15 -0400 Message-Id: <20050722165558.M96628@contactbda.com> In-Reply-To: <200507221149.21550.mark.dingee@cox.net> References: <200507221149.21550.mark.dingee@cox.net> X-Mailer: Open WebMail 2.41 20040926 X-OriginatingIP: 192.168.1.1 (jim) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/194 X-Sequence-Number: 22172 Mark, Instead of RETURN NEXT rec.txt1; RETURN NEXT rec.txt2; just use RETURN NEXT rec; then your select statement would be select * from my_func() as (txt1 text,txt2 text); Jim ---------- Original Message ----------- From: "Mark R. Dingee" To: pgsql-sql@postgresql.org Sent: Fri, 22 Jul 2005 11:49:21 -0400 Subject: [SQL] Multi-column returns from pgsql > Hi Everyone, > > Does anyone know if/how it's possible to return multi-column sets from a pgsql > function? Right now I'm using something like the following as a work around > > CREATE OR REPLACE FUNCTION my_func() returns SETOF TEXT AS ' > DECLARE > rec record; > BEGIN > FOR rec IN SELECT txt1, txt2 FROM mytable LOOP > RETURN NEXT rec.txt1; > RETURN NEXT rec.txt2; > END LOOP; > RETURN; > END;' language 'plpgsql'; > > which leaves me parsing multiple records to achieve the desired end result. > > Anyone have any thoughts? > > Thanks, > Mark > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match ------- End of Original Message -------