Re: Converting between varchar and float when updating - Mailing list pgsql-general

From Dmitriy Igrishin
Subject Re: Converting between varchar and float when updating
Date
Msg-id BANLkTik1fL6g59-4rWvrKVJbwBeeeWRUpw@mail.gmail.com
Whole thread Raw
In response to Re: Converting between varchar and float when updating  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
Responses Re: Converting between varchar and float when updating
List pgsql-general


2011/4/28 Vibhor Kumar <vibhor.kumar@enterprisedb.com>

On Apr 28, 2011, at 2:56 PM, Thomas Larsen Wessel wrote:

> UPDATE foo SET bar = TO_VARCHAR( TO_FLOAT(bar) * 2); -- INCORRECT!!!!

If you are sure bar contains float value, then try following:
UPDATE foo SET bar = bar::float * 2;
NB:  I am sure that OP is not sure :-) And since foo.bar is varchar,
it is better to use numeric instead of float :-)

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
// Dmitriy.


pgsql-general by date:

Previous
From: Vibhor Kumar
Date:
Subject: Re: Converting between varchar and float when updating
Next
From: Dmitriy Igrishin
Date:
Subject: Re: Converting between varchar and float when updating