selecting for type cast failures

Поиск
Список
Период
Сортировка
Искать
От
Natalie Wenz
Тема
selecting for type cast failures
Дата
Msg-id
50077521-C61D-4050-B13D-A73D31A7C35B@ebureau.com
Список
Дерево обсуждения
selecting for type cast failures Natalie Wenz <nataliewenz@ebureau.com>
Re: selecting for type cast failures Guy Rouillier <guy.rouillier@gmail.com>
Re: selecting for type cast failures Adrian Klaver <adrian.klaver@gmail.com>
Re: selecting for type cast failures David Johnston <polobo@yahoo.com>
Re: selecting for type cast failures Adrian Klaver <adrian.klaver@gmail.com>
Hi!

I am working on updating some of our tables to use appropriate native data types;  they were all defined as text when they were created years ago.

What I am running into, though, is there are some records that have bad data in them, where they can't be successfully converted to int, or float, or boolean, for example. 

Is there a straightforward way to identify offending records? 

I've been able to identify some with things like "...not similar to '(0|1)'..." for the boolean fields, and "...not similar to '[0-9]{1,}'..." for int. 
Are regular expressions the best approach here or is there a better way? 

Thoughts?

I've poked around on the internet and have found some people suggesting user-defined functions. I'd prefer to just use a query, since it's a one-time clean-up.

(I'm using postgres 9.2)


Thanks!
Natalie
В списке pgsql-general по дате отправления
От: akp geek
Дата:
От: François Beausoleil
Дата:
FAQ