X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AEBE614B281D for ; Wed, 11 Aug 2004 05:24:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93636-08 for ; Wed, 11 Aug 2004 08:24:43 +0000 (GMT) Received: from poweredge.attiksystem.ch (adsl-soholight-4-c59-p029.vtx.ch [212.147.59.29]) by svr1.postgresql.org (Postfix) with ESMTP id 6A51D14B2806 for ; Wed, 11 Aug 2004 05:24:40 -0300 (ADT) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: function expression in FROM may not refer to other relations of same query level X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Date: Wed, 11 Aug 2004 10:24:42 +0200 content-class: urn:content-classes:message Message-ID: <6C0CF58A187DA5479245E0830AF84F420803B4@poweredge.attiksystem.ch> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] function expression in FROM may not refer to other relations of same query level Thread-Index: AcR/AVb2CrivVIiqQ0SMUBB2bgP1rwAbFsdQAANSqbA= From: "Philippe Lang" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/81 X-Sequence-Number: 18578 I found one solution: select id, usr, code, (get_lines(code)).line1, (get_lines(code)).line2 from tbl; The problem now is that get_lines is being called twice per line. (I check = with a RAISE NOTICE). Philippe -----Message d'origine----- De : pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]= De la part de Philippe Lang Envoy=E9 : mercredi, 11. ao=FBt 2004 08:41 =C0 : pgsql-sql@postgresql.org Objet : Re: [SQL] function expression in FROM may not refer to other relati= ons of same query level Hello, > Whats wrong with just using CASE: >=20 > select id, usr, code, > case when code =3D 1 then 'A' else 'Z' end as line1, > case when code =3D 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 not sure it's possible to implement it with a SE= LECT... CASE. What's more, the "get_lines" function already exists, and is = already used in different parts of the database. I would like, if possible,= to use it without changing it, or duplicating code. Philippe ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org