pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ERROR: function expression in FROM may not refer to other relations of same query level
2+ messages / 2 participants
[nested] [flat]

* ERROR: function expression in FROM may not refer to other relations of same query level
@ 2009-07-09 01:22 Joseph S <jks@selectacast.net>
  2009-07-09 01:58 ` Re: ERROR: function expression in FROM may not refer to other relations of same query level Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Joseph S @ 2009-07-09 01:22 UTC (permalink / raw)
  To: pgsql-sql

I've seen this asked in the archives, but there was never any answer.

Supposed I have this table:

create temp table tempa (ids int[]);
insert into tempa SELECT ARRAY[1 , 2, 3];

Now how do I get output from that?  None of these work: (xunnest is my 
version of unnest since I'm using 8.2.x)


select * FROM xunnest(tempa.ids);

SELECT * FROM (select * FROM xunnest(tempa.ids) AS aa) AS ab, tempa;

SELECT * FROM ( select * FROM xunnest(ta.ids) AS aa) AS ab, tempa ta;

SELECT * FROM tempa ta, ( select * FROM xunnest(ta.ids) AS aa) AS ab;



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ERROR: function expression in FROM may not refer to other relations of same query level
  2009-07-09 01:22 ERROR: function expression in FROM may not refer to other relations of same query level Joseph S <jks@selectacast.net>
@ 2009-07-09 01:58 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2009-07-09 01:58 UTC (permalink / raw)
  To: Joseph S <jks@selectacast.net>; +Cc: pgsql-sql

Joseph S <jks@selectacast.net> writes:
> Supposed I have this table:

> create temp table tempa (ids int[]);
> insert into tempa SELECT ARRAY[1 , 2, 3];

> Now how do I get output from that?

Uh, you didn't actually say what output you're looking for, but
I'm going to guess it's this:

regression=# select unnest(ids) from tempa;
 unnest 
--------
      1
      2
      3
(3 rows)

Pre-8.4, you need a version of unnest() that's coded in C or SQL;
plpgsql won't do.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2009-07-09 01:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-07-09 01:22 ERROR: function expression in FROM may not refer to other relations of same query level Joseph S <jks@selectacast.net>
2009-07-09 01:58 ` Tom Lane <tgl@sss.pgh.pa.us>

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