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 AC5289FB219 for ; Thu, 27 Jul 2006 18:10:26 -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 56309-06 for ; Thu, 27 Jul 2006 18:10:13 -0300 (ADT) X-Greylist: delayed 00:27:55.213188 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C7E409FB21A for ; Thu, 27 Jul 2006 18:09:43 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from fuse1.mailanyone.net (unknown [69.31.1.141]) by svr4.postgresql.org (Postfix) with ESMTP id 97F2A5AF025 for ; Thu, 27 Jul 2006 20:41:44 +0000 (GMT) Received: from mailanyone.net by fuse1.mailanyone.net with asmtp (MailAnyone extSMTP chris@blendinteractive.com) id 1G6Cfj-0006Fb-6N for pgsql-sql@postgresql.org; Thu, 27 Jul 2006 15:41:31 -0500 Received: from 208.107.92.43 (FuseMail web AccountID 168507) by webmail.fusemail.com with HTTP; Thu, 27 Jul 2006 15:41:31 -0500 (CDT) Message-ID: <1154032891.v2.fusewebmail-168507@ffuse18> Date: Thu, 27 Jul 2006 15:41:31 -0500 (CDT) Subject: return setof records From: "Chris Lukenbill" To: pgsql-sql@postgresql.org Reply-To: chris@blendinteractive.com User-Agent: FuseMail W MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200607/343 X-Sequence-Number: 25917 Alright, first I'll apologize for asking this question another time. I've looked throught the archives and have found different ways on both the archives and different ways in the the documentation to do this and depending on which way I do it, I get different errors, so pick your poison on that. 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); So there isn't a question on that. My question is, how do I return a "setof record" back to the application. I've tried the following ways: --------------------------------------------------------- CREATE OR REPLACE FUNCTION sp_frontalerts_summary (p_usernum int, p_lastlogin TIMESTAMP,p_now TIMESTAMP) RETURNS SETOF RECORD AS $$ DECLARE returnRecord RECORD; BEGIN FOR returnRecord in select count(item) as numitems,0 as region from frontalerts where usernum=p_usernum and pinup=0 LOOP RETURN NEXT returnRecord; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; --------------------------------------------------------- Also have tried it with EXECUTE after the "FOR returnRecord in" and before the "select count(item)..." Also have tried to do just a "select count(item) as numitems,0 as region from frontalerts where usernum=p_usernum and pinup=0" without any type of returning (only a "RETURNS SETOF RECORD AS $$..") (the way that the documentation talks about doing it in one area) Now this is a little of a simplified version, but I have the same problem with all of the stored procs. If you know what I'm doing wrong, please let me know. Or if you have anything I should possibly try, let me know that too. I've searched high and low and really thought I had it this time, but I guess not. Also, sorry for such an easy question, but I'm new to PostgreSQL so this port from MS SQL to PostgreSQL on someone else's code is kickin my butt. Thank you in adavance for any help. Chris