Re: Is it possible to default all number data to numeric type?

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Pls Help Me <plshelpme(at)my-deja(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is it possible to default all number data to numeric type?
Date: 2001-09-04 14:10:48
Message-ID: 200109041410.f84EAma01655@jupiter.us.greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pls Help Me wrote:
> My company had a old program with written by Powerbuilder. It work
> fine in MSSQL 6.5.
> Now, my boss required to use another SQL server. Someone told me
> PostgreSQL is totally free and powerful. I installed it in a Linux
> machine (RedHat 7 + PostgreSQL 7.1.2), and transfer the old data from
> MSSQL 6.5 server. It work fine.
> However, when I run the old program. When I try to update some record
> with numeric type field, it show error as below.
>
> Unable to identify an operator '=' for types 'numeric' and 'float8'...
> You will have to retype this query using an explicit cast.

Looks like the application does some

SELECT ... WHERE some_numeric_attrib = 1234.56 ...

The point here is, that a constant like above (1234.56) get's
parsed into a float8 and there is no = operator defined for
numeric and float8. It is not sufficient to define an
operator, because the conversion of the characters 1234.56
into a float8 value looses precision, so the comparision with
a true numeric attribute might result in false, even if it
should've been true.

> The point is the software house closed, I can't find any programmer.
> >_<
> So, I want to know is it possible to set the numeric type to default??
> Or any easy way to fix it up?

If the vendor doesn't exist any more, I hope you have the
sources!

If so, you could cast the constant values in the queries
explicitly to numeric data type by changing 1234.56 into
'1234.56'::numeric.

> P.S. My English is bad, pls. forgive me.

Compared to what some english native speakers scribble, it's
excellent. And this mailing list focuses on solving
PostgreSQL problems anyway. As long as we can figure out what
someones problem is, noone will complain.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Asher 2001-09-04 14:17:25 upgrade from 7.1.2 to 7.1.3 and uh, where are my databases?
Previous Message Tom Lane 2001-09-04 14:01:45 Re: nested SQL with SPI