pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Boes <jeff@endpoint.com>
To: pgsql-sql@postgresql.org
Subject: Joins involving functions
Date: Fri, 07 Apr 2006 17:01:55 -0400
Message-ID: <4436D343.5010802@endpoint.com> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <4436D343.5010802@endpoint.com>
Permalink:  ../4436D343.5010802@endpoint.com/
Also on:    postgresql.org/message-id/4436D343.5010802@endpoint.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jeff@endpoint.com
  Subject: Re: Joins involving functions
  In-Reply-To: <4436D343.5010802@endpoint.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox