Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 78266637D18 for ; Thu, 2 Apr 2009 20:22:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 18297-09 for ; Thu, 2 Apr 2009 20:22:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp1.islandnet.com (smtp1.islandnet.com [199.175.106.100]) by mail.postgresql.org (Postfix) with ESMTP id B6F126331A0 for ; Thu, 2 Apr 2009 20:22:09 -0300 (ADT) Received: from [199.175.106.50] (port=34188 helo=cluster.islandnet.com) by smtpout.islandnet.com with ESMTP id 1LpWEZ-0002gj-2t ; Thu, 02 Apr 2009 16:22:07 -0700 Received: from [24.108.1.50] (port=2878 helo=[192.168.0.193]) by cluster01.islandnet.com with ESMTPSA (TLSv1:AES256-SHA:256) id 1LpWEZ-0003gZ-3L ; Thu, 02 Apr 2009 16:22:07 -0700 Message-ID: <49D5489E.5010904@borstad.com> Date: Thu, 02 Apr 2009 16:22:06 -0700 From: Peter Willis Reply-To: peterw@borstad.com User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Adrian Klaver CC: pgsql-sql@postgresql.org Subject: Re: FUNCTION problem References: <1521645855.2691471238710811603.JavaMail.root@sz0030a.emeryville.ca.mail.comcast.net> In-Reply-To: <1521645855.2691471238710811603.JavaMail.root@sz0030a.emeryville.ca.mail.comcast.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/24 X-Sequence-Number: 32370 Adrian Klaver wrote: > > > Did you happen to catch this: > Note that functions using RETURN NEXT or RETURN QUERY must be called as a table source in a FROM clause > > Try: > select * from test_function(1) > I did miss that, but using that method to query the function didn't work either. Postgres doesn't see the result as a tabular set of records. Even if I replace the FOR loop with: FOR R IN SELECT * FROM pg_database LOOP RETURN NEXT R; END LOOP; I get the same error(s). I don't think postgres likes the unrelated 'SELECT INTO [column] FROM [QUERY] LIMIT 1' lines before the FOR loop... I think I need to go back and approach the function from a different direction. Thanks for all the pointers. Peter