| От | Arnaud Lesauvage |
|---|---|
| Тема | Function testing if a string is a number ? |
| Дата | |
| Msg-id | 43F9CEDB.8000605@freesurf.fr обсуждение исходный текст |
| Ответы |
Re: Function testing if a string is a number ?
|
| Список | pgsql-novice |
Hi list !
I am searching for a function that would return true if a string
is a number.
In Access I would have written IsNumeric('mystring'), but this
function does not exist in postgres.
Maybe I am doing this the wrong way actually : I want to fill an
integer field with the values from a varchard field. Some of the
values are not convertible though, so just executing :
UPDATE thetable
SET numfield=varcharfield::int4;
returns an error 'Invalid input syntax for integer "blablabla"'.
My idea was to run :
UPDATE thetable
SET numfield=varcharfield::int4
WHERE IsNumeric(varcharfield);
but maybe there is a better way to achieve this ?
Thanks for your help !
Regards
--
Arnaud
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера