Converting between varchar and float when updating
От | Thomas Larsen Wessel |
---|---|
Тема | Converting between varchar and float when updating |
Дата | |
Msg-id | BANLkTi=aB3wgGOrVBnn7TVM8MouidrjQGg@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Converting between varchar and float when updating
Re: Converting between varchar and float when updating Re: Converting between varchar and float when updating Re: Converting between varchar and float when updating |
Список | pgsql-general |
I have a table with the following schema:
CREATE TABLE foo (bar VARCHAR(32));
Every bar value has a format like a float, e.g. "2.5". Now I want that value multiplied by two and saved again as varchar. I was hoping to do smth like:
UPDATE foo SET bar = TO_VARCHAR( TO_FLOAT(bar) * 2); -- INCORRECT!!!!
How is that done?
I know that the bar attribute ought to have type FLOAT, but I have to work with this legacy database. And anyway this table will rarely be updated.
Sincerely, Thomas
CREATE TABLE foo (bar VARCHAR(32));
Every bar value has a format like a float, e.g. "2.5". Now I want that value multiplied by two and saved again as varchar. I was hoping to do smth like:
UPDATE foo SET bar = TO_VARCHAR( TO_FLOAT(bar) * 2); -- INCORRECT!!!!
How is that done?
I know that the bar attribute ought to have type FLOAT, but I have to work with this legacy database. And anyway this table will rarely be updated.
Sincerely, Thomas
В списке pgsql-general по дате отправления: