pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alessio Bragadini <alessio@albourne.com>
To: jkakar@expressus.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Bounds checking on an alias
Date: Tue, 19 Dec 2000 16:45:36 +0200
Message-ID: <3A3F7490.46EE0F0F@albourne.com> (raw)
References: <20001218171134.A4581@expressus.com>

jkakar@expressus.com wrote:

> SELECT DISTINCT tbl_restaurant.restaurant,
> tbl_restaurant_location.postal_code, tbl_restaurant_location.latitude
> AS latitude, tbl_restaurant_location.longitude AS longitude, distance
> (49.24894, -122.90419, latitude, longitude) AS distance FROM
> tbl_restaurant, tbl_restaurant_location, tbl_restaurant_cuisine_link
> WHERE tbl_restaurant.restaurant_id =
> tbl_restaurant_location.restaurant_id AND tbl_restaurant.restaurant_id
> = tbl_restaurant_cuisine_link.restaurant_id AND
> tbl_restaurant_cuisine_link.cuisine_id = 14 AND
> tbl_restaurant.price_id = 1 AND tbl_restaurant_location.latitude IS
> NOT NULL AND tbl_restaurant_location.latitude > 49.113804 AND
> tbl_restaurant_location.latitude < 49.384075 AND
> tbl_restaurant_location.longitude > -123.03932 AND
> tbl_restaurant_location.longitude < -122.76906 AND distance <= 15.0
> ORDER BY distance;

> ERROR:  Attribute 'distance' not found

It's not related to your function or query, but it's a generic
behaviour:

changemaster=# select id + 1 as next, val from t;
 next | val
------+------
    2 | Test
(1 row)
 
changemaster=# select id + 1 as next, val from t where next > 1;
ERROR:  Attribute 'next' not found
changemaster=# select id + 1 as next, val from t where id + 1 > 1;
 next | val
------+------
    2 | Test
(1 row)
                                                                                
The named expression isn't available in the WHERE clause. You have to
copy the same expression in it.

-- 
Alessio F. Bragadini		alessio@albourne.com
APL Financial Services		http://village.albourne.com
Nicosia, Cyprus		 	phone: +357-2-755750

"It is more complicated than you think"
		-- The Eighth Networking Truth from RFC 1925



view thread (2+ messages)

Message-ID: <3A3F7490.46EE0F0F@albourne.com>
Permalink:  ../3A3F7490.46EE0F0F@albourne.com/
Also on:    postgresql.org/message-id/3A3F7490.46EE0F0F@albourne.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: alessio@albourne.com, jkakar@expressus.com
  Subject: Re: Bounds checking on an alias
  In-Reply-To: <3A3F7490.46EE0F0F@albourne.com>
  References: <20001218171134.A4581@expressus.com> <3A3F7490.46EE0F0F@albourne.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox