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 A632514B281D for ; Wed, 11 Aug 2004 03:41:24 -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 59522-06 for ; Wed, 11 Aug 2004 06:41:19 +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 D093E14B281B for ; Wed, 11 Aug 2004 03:41:06 -0300 (ADT) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 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 08:41:07 +0200 content-class: urn:content-classes:message Message-ID: <6C0CF58A187DA5479245E0830AF84F420803B3@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/AVb2CrivVIiqQ0SMUBB2bgP1rwAbFsdQ 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/80 X-Sequence-Number: 18577 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;=20 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 SELECT... 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