Re: Converting between varchar and float when updating

From: Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com>
To: Thomas Larsen Wessel <mrvelle(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Converting between varchar and float when updating
Date: 2011-04-28 09:49:57
Message-ID: C3BCAB90-FEA3-4D25-A9E8-AF46D521A286@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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;

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitriy Igrishin 2011-04-28 09:52:18 Re: Converting between varchar and float when updating
Previous Message Szymon Guz 2011-04-28 09:41:56 Re: Converting between varchar and float when updating