X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8033211F65FC for ; Fri, 7 Apr 2006 18:08:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45062-06 for ; Fri, 7 Apr 2006 18:08:40 -0300 (ADT) X-Greylist: delayed 00:06:40.357431 by SQLgrey- Received: from qtm.net (mummra.qtm.net [216.163.32.14]) by postgresql.org (Postfix) with SMTP id 97AF811F6026 for ; Fri, 7 Apr 2006 18:08:42 -0300 (ADT) Received: (qmail 68495 invoked from network); 7 Apr 2006 21:00:43 -0000 Received: from unknown (HELO ?192.168.1.4?) (mur@216.163.42.3) by mummra.qtm.net with SMTP; 7 Apr 2006 21:00:43 -0000 Message-ID: <4436D343.5010802@endpoint.com> Date: Fri, 07 Apr 2006 17:01:55 -0400 From: Jeff Boes Organization: End Point, Inc. User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Joins involving functions X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200604/74 X-Sequence-Number: 24883 I have a function that returns a row from a table, e.g.: create table foo (a integer); create function f_foo (integer) returns foo language 'sql' as $foo$ select * from foo where a = $1 limit 1 $foo$ create table bar (b integer); select * from bar cross join f_foo(bar.b) as foo; Unfortunately, this last statement returns an error: NOTICE: adding missing FROM-clause entry for table "bar" ERROR: function expression in FROM may not refer to other relations of same query level Is there a method for joining function calls to tables? The only other approach I can think of is to write another function that returns "setof". -- Jeffery Boes <>< jeff@endpoint.com