Re: RFE: Column aliases in WHERE clauses

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Chris Angelico'" <rosuav(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: RFE: Column aliases in WHERE clauses
Date: 2012-09-20 12:45:11
Message-ID: 00f901cd972d$c6dae850$5490b8f0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> On Wed, Sep 19, 2012 at 11:15 PM, David Johnston <polobo(at)yahoo(dot)com>
> wrote:
> > I could maybe see something like the following having some value:
> >
> > SELECT inverse
> > FROM data
> > WHERE x<>0 AND inverse > .5
> > MACRO inverse (1/x)
> >
>
> WITH macros AS (SELECT *,1/x AS inverse FROM data) SELECT inverse FROM
> macros WHERE x<>0 AND inverse > .5
>

In your example the "macro" has to either be attached directly to the FROM
or be used as part of a sub-select; it is not a text substitution macro at
all. The pre-processor upon encountering a macro, would simply replace all
identifiers (at the same level in the query) with "(expression)".

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-09-20 12:57:49 Re: Need psql send email
Previous Message Craig Ringer 2012-09-20 12:44:50 Re: Passing row set into PL/pgSQL function.