Thread: Matching types

Matching types

From
Vicente Alabau Gonzalvo
Date:
Does anybody know how to get BigDecimal from numeric and how to put
BigDecimal to numeric using jdbc?
The first thing seems to work automaticaly.
BigDecimal seems to be converted into double precision when put in a
query. Then it can't be compared with a numeric value.

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

Can it be done without doing an explicit cast?

Thanks in advance.


Re: Matching types

From
Daniel Serodio
Date:
I had the same problem. It's a backend problem, not JDBC related. If you
try to "select val2 from test where val1=123.45" in a table defined as
"create table test (val1 numeric, val2 int)" in psql or any other
frontend you will have the exact same problem.

I was told that this would be fixed in PostgreSQL 7.3, but I don't have
a 7.3 server to check if it was fixed or not.

Bottom line: use an explicit cast. That's how we solved it. BTW, you
need to use explicit casts anyway if you want the server to use indices.

Hope this helps,
Daniel Serodio

On Mon, 2003-02-03 at 06:01, Vicente Alabau Gonzalvo wrote:
> Does anybody know how to get BigDecimal from numeric and how to put
> BigDecimal to numeric using jdbc?
> The first thing seems to work automaticaly.
> BigDecimal seems to be converted into double precision when put in a
> query. Then it can't be compared with a numeric value.
>
> ERROR:  Unable to identify an operator '=' for types 'numeric' and
> 'double precision'
>   You will have to retype this query using an explicit cast
>
> Can it be done without doing an explicit cast?
>
> Thanks in advance.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Daniel Serodio <daniel@checkforte.com.br>
CheckForte