Alias in WHERE clause - Mailing list pgsql-general

From Eric Jain
Subject Alias in WHERE clause
Date
Msg-id NCBBJFHBEGOIAHBCBNCLAEPJCEAA.jain@gmx.net
Whole thread Raw
Responses Re: Alias in WHERE clause  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: Alias in WHERE clause  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I would like to be able to say:

SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles
WHERE score > 0
ORDER BY score DESC;

This returns: ERROR:  Attribute 'score' not found.

The following works:

SELECT url,score_a(text, CAST('term' AS TEXT)) AS score FROM articles
WHERE score_a(text, CAST('term' AS TEXT)) > 0
ORDER BY score DESC;

Doesn't seem efficient to me? Or are the results from score_a cached
somehow?

score_a is a (rather computation-intensive :-) PL/Perl function which
returns an integer.

I am using PostgreSQL 7.0


--
Eric Jain


pgsql-general by date:

Previous
From: "Stephan Szabo"
Date:
Subject: Re: rules on INSERT can't UPDATE new instance?
Next
From: Giles Lean
Date:
Subject: Re: Columns in pg_shadow?