Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group