X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 967069FB281 for ; Fri, 28 Jul 2006 14:43:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 67891-08 for ; Fri, 28 Jul 2006 14:43:35 -0300 (ADT) X-Greylist: delayed 01:23:19.544968 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 91DE79FB263 for ; Fri, 28 Jul 2006 14:43:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr4.postgresql.org (Postfix) with ESMTP id 126955AFB97 for ; Fri, 28 Jul 2006 14:15:10 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.7/8.13.7) with ESMTP id k6SEDn6w020437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Jul 2006 08:13:53 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k6SEDn82095323; Fri, 28 Jul 2006 08:13:49 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k6SEDnLn095322; Fri, 28 Jul 2006 08:13:49 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 28 Jul 2006 08:13:49 -0600 From: Michael Fuhr To: Chris Lukenbill Cc: pgsql-sql@postgresql.org Subject: Re: return setof records Message-ID: <20060728141348.GA95234@winnie.fuhr.org> References: <1154032891.v2.fusewebmail-168507@ffuse18> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1154032891.v2.fusewebmail-168507@ffuse18> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.727 tagged_above=0 required=5 tests=AWL, SPF_FAIL X-Spam-Level: X-Archive-Number: 200607/358 X-Sequence-Number: 25932 On Thu, Jul 27, 2006 at 03:41:31PM -0500, Chris Lukenbill wrote: > Everywhere I've looked the agreement was that making a call to the > function had to be done as follows: > > SELECT * FROM sp_frontalerts_summary(1,'2006-07-27 18:08:09','2006-07-27 > 19:58:15' ) as (numitems int, region int); That's one way. Another way would be for the function to use OUT parameters (if you're running 8.1) or to return a custom type so you could omit the column definition list. Then the query would be: SELECT * FROM sp_frontalerts_summary(1, '2006-07-27 18:08:09', '2006-07-27 19:58:15'); > So there isn't a question on that. My question is, how do I return a > "setof record" back to the application. The function and how you're calling it look correct except that count() returns bigint, not int. You didn't mention what error you're getting but I'd guess it's "wrong record type supplied in RETURN NEXT". Try using "numitems bigint" instead of "numitems int". -- Michael Fuhr