Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 39C07475852 for ; Fri, 5 Jul 2002 22:18:22 -0400 (EDT) Mailbox-Line: From pgman@candle.pha.pa.us Fri Jul 5 22:18:22 2002 Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (Postfix) with ESMTP id 18E544768B7 for ; Fri, 5 Jul 2002 22:17:19 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g662HGT11627; Fri, 5 Jul 2002 22:17:16 -0400 (EDT) From: Bruce Momjian Message-Id: <200207060217.g662HGT11627@candle.pha.pa.us> Subject: Re: How do i return a dataset from a stored procedure In-Reply-To: <20020705162117.GA14809@cc.usu.edu> To: Roberto Mello Date: Fri, 5 Jul 2002 22:17:16 -0400 (EDT) Cc: teknokrat , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, hits=-3.4 required=5.0 tests=IN_REP_TO version=2.30 X-Spam-Level: X-Archive-Number: 200207/73 X-Sequence-Number: 8452 Roberto Mello wrote: > On Fri, Jul 05, 2002 at 01:32:33AM -0700, teknokrat wrote: > > I can't figure out how to return a group of rows from a function > > written in plpgsql (or plsql for that matter). The only way i have > > seen it done is with a setof table return value in sql. But since the > > query was a single select anyway i don't see the point of this. Is > > there a way of creating a temporary table in a procedure and using it > > as the output? > > Search the list archives (through groups.google.com - it's > comp.databases.postgresql) or see the developer docs for PL/pgSQL. You > can achive that effect by returning a cursor in PG 7.2 (the section on > returning cursors is ommitted from the current docs in > www.postgresql.org/idocs, so you need to look at the developer docs - see > www.us.postgresql.org). 7.3 will have better docs on using it but you can see them now in the developers docs: http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html See the bottom of that page for examples. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026