Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4A21A634A71 for ; Mon, 13 Jul 2009 15:27:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 81437-02 for ; Mon, 13 Jul 2009 15:27:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by mail.postgresql.org (Postfix) with ESMTP id E977B636479 for ; Mon, 13 Jul 2009 15:21:35 -0300 (ADT) Received: from perhan.alvh.no-ip.org (201-220-118-158.bk10-dsl.surnet.cl [201.220.118.158]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id n6DIU8jZ011839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Jul 2009 11:30:11 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C8254D419B; Mon, 13 Jul 2009 14:21:30 -0400 (CLT) Date: Mon, 13 Jul 2009 14:21:30 -0400 From: Alvaro Herrera To: Surajit Bhattacharjee Cc: pgsql-sql@postgresql.org Subject: Re: function returning a cursor and a scalar Message-ID: <20090713182130.GG4930@alvh.no-ip.org> References: <75F63F40B35C3144854E90019EB086770DDC0229@ws-mailsvr.Virtusa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <75F63F40B35C3144854E90019EB086770DDC0229@ws-mailsvr.Virtusa.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Mon, 13 Jul 2009 11:30:11 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL=0.006 X-Spam-Level: X-Archive-Number: 200907/67 X-Sequence-Number: 32808 Surajit Bhattacharjee wrote: > I am new to Postgresql and am trying to write a function which will do a > search and return the first page of results along with the total number > of matches. How can I make my function return a cursor AND a scalar - > can I do the scalar as an OUT param and then make the function > explicitly RETURN a refcursor? Why wouldn't you just use two OUT params? BTW how do you plan on returning the number of matches? -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support