Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-13 Thread Philippe Lang
om ( select id, usr, code, get_lines(code) as get_lines_data from tbl offset 0 ) as ss; --- Philippe Lang -Message d'origine----- De : Tom Lane [mailto:[EMAIL PROTECTED] Envoyé : jeudi, 12. août 2004 16:31 À : Philippe Lang

Re: [SQL] function expression in FROM may not refer to other relations

2004-08-12 Thread Stephan Szabo
On Thu, 12 Aug 2004, Philippe Lang wrote: > > > The problem now is that get_lines is being called twice per line. > > > > Is get_lines() defined as IMMUTABLE? Should it be? > > I have tried defining get_lines as "IMMUTABLE", or "WITH (iscachable)", > but it keeps on getting called twice per line

Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-12 Thread Tom Lane
"Philippe Lang" <[EMAIL PROTECTED]> writes: > I wish there was a way to run the query like this: > select > id, > usr, > code, > CAST(get_lines(code) as lines) > from tbl; You can do something like this: regression=# create type complex as (r float8, i float8); CREATE TYPE regression=# c

Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-12 Thread Philippe Lang
> > The problem now is that get_lines is being called twice per line. > > Is get_lines() defined as IMMUTABLE? Should it be? I have tried defining get_lines as "IMMUTABLE", or "WITH (iscachable)", but it keeps on getting called twice per line in the following query... select id, usr, code

Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-11 Thread Rosser Schwarz
Philippe Lang wrote: > The problem now is that get_lines is being called twice per line. Is get_lines() defined as IMMUTABLE? Should it be? /rls -- :wq ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-11 Thread Philippe Lang
EMAIL PROTECTED] De la part de Philippe Lang Envoyé : mercredi, 11. août 2004 08:41 À : [EMAIL PROTECTED] Objet : Re: [SQL] function expression in FROM may not refer to other relations of same query level Hello, > Whats wrong with just using CASE: > > select id, usr, code, > case when

Re: [SQL] function expression in FROM may not refer to other relations of same query level

2004-08-10 Thread Philippe Lang
Hello, > Whats wrong with just using CASE: > > select id, usr, code, > case when code = 1 then 'A' else 'Z' end as line1, > case when code = 1 then 'A' else 'Z' end as line2 from tbl; The code I showed in my last mail was actually test code only. The logic is more complicated, and I'm n

Re: [SQL] function expression in FROM may not refer to other relations

2004-08-10 Thread Joe Conway
Philippe Lang wrote: But the same query with a parameter returns an error: select id, usr, code, line1, line2 from tbl, get_lines(code); --> ERROR: function expression in FROM may not refer to other relations of same query level This is as expected and required -- you cannot refer to other FROM

[SQL] function expression in FROM may not refer to other relations of same query level

2004-08-10 Thread Philippe Lang
Hello, I'm trying to use the ROWTYPE return value of a plpgsql function in a SELECT query. The test code is below. The following query is accepted: select id, usr, code, line1, line2 from tbl, get_lines(1); idusr code line1 line2 -- 1 one 1