Re: Casting numeric values to double

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Casting numeric values to double
Дата
Msg-id 20051003154406.GC15212@svana.org
обсуждение исходный текст
Ответ на Casting numeric values to double  ("Daniel Schregenberger" <npfdd@gmx.net>)
Ответы Re: Casting numeric values to double  (Daniel Schregenberger <npfdd@gmx.net>)
Список pgsql-general
On Mon, Oct 03, 2005 at 03:31:42PM +0200, Daniel Schregenberger wrote:
> Hi,
>
> I recently stumbled uppon the following thing:
> If I compare a field of type "numeric" to a small decimal constant like
> "3.6", the constant is interpreted as a "double precision" value and the
> comparison fails with the following message:
>
> # SELECT * FROM tr_table_okpx WHERE prating >= 3.6;
>
> Unable to identify an operator '>=' for types 'double precision' and
> 'numeric'
>         You will have to retype this query using an explicit cast

If at all possible, can the queries be arranged to output single quotes
around the numbers? If you do that, the choice of type will be deferred
until the point where it knows what "prating" is.

> I'm using Postgre 7.2, which might be a bit outdated but I could not find
> any information whether this behaviour has changed in newer versions. So

Yeah, it's better in later versions. Either explicitly typing (with
::numeric) or explicitly untyping (with single quotes) will work.
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Nirmalya Lahiri
Дата:
Сообщение: Re: Broken pipe
Следующее
От: J B
Дата:
Сообщение: Integration with MS Sql Server