Re: Problem with numeric and operators

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: DaVinci <bombadil(at)wanadoo(dot)es>
Cc: Lista PostgreSql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem with numeric and operators
Date: 2001-09-04 12:33:58
Message-ID: 200109041233.f84CXw8s008279@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

DaVinci wrote:
> Hi all.
>
> I have a problem with data type 'numeric'. If I have a field of type
> 'numeric' (in this case 'foo') and execute next query:
>
> select * from table_example where foo > 2.45
>
> I get error:
>
> ERROR: Unable to identify an operator '>' for types 'numeric' and 'flo
>at8'
> You will have to retype this query using an explicit cast
>
> What is the meaning of this? Is it a bug? What am I doing wrong?...

There is not yet an automatic type conversion for such cases.

Add an explicit cast to your query:

select * from table_example where foo > CAST (2.45 AS NUMERIC(12,2))

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"If any of you lack wisdom, let him ask of God, who
gives to all men generously and without reproach, and
it will be given to him." James 1:5

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-09-04 14:01:45 Re: nested SQL with SPI
Previous Message DaVinci 2001-09-04 12:08:36 Problem with numeric and operators