Обсуждение: [General] Unable to identify an operator '=' for types 'numeric' and 'double precision' You will have to retype this query using and explicit cast

Поиск
Список
Период
Сортировка
Server hardware:
Pentium 166mmx
96mb ram
4gb HD

Server Software:
Red Hat Linux 7.1
PostgreSQL 7.2

Development:
PowerBuilder 5.0

The story start when I try these statements (execute in psql):

CREATE TABLE testdecimal ( decimal_value DECIMAL(6,2));
INSERT INTO testdecimal VALUES(1.0);
INSERT INTO testdecimal VALUES(1.1);
SELECT * FROM testdecimal WHERE decimal_value = 1.0;

Error : Unable to identify an operator '=' for types 'numeric' and 'double
precision'
        You will have to retype this query using and explicit cast


引言 Andrew Sullivan <andrew@libertyrms.info>:

> On Mon, Mar 11, 2002 at 11:45:07AM +0800, Edmund Lim Chi Chung wrote:
> >
> > CREATE TABLE testdecimal ( decimal_value DECIMAL(6,2));
> > INSERT INTO testdecimal VALUES(1.0);
> > INSERT INTO testdecimal VALUES(1.1);
> > SELECT * FROM testdecimal WHERE decimal_value = 1.0;
> >
> > Error : Unable to identify an operator '=' for types 'numeric' and
> 'double
> > precision'
> >         You will have to retype this query using and explicit cast
>
> You'll need to recast, like it says.  Try
>
>     SELECT * FROM testdecimal WHERE decimal_value = 1.0::decimal;
>
> A
>
> --
> ----
> Andrew Sullivan                               87 Mowat Avenue
> Liberty RMS                           Toronto, Ontario Canada
> <andrew@libertyrms.info>                              M6K 3E3
>                                          +1 416 646 3304 x110
>
>


Found two more method:
      SELECT * FROM testdecimal WHERE decimal_value = '1.0';

      SELECT * FROM testdecimal WHERE decimal_value = CAST( 1.0 AS decimal );