Re: Cast char to number

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: Cast char to number
Дата
Msg-id 20100224170313.fce5161b.wmoran@potentialtech.com
обсуждение исходный текст
Ответ на Re: Cast char to number  (Raymond O'Donnell <rod@iol.ie>)
Ответы Re: Cast char to number  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
In response to Raymond O'Donnell <rod@iol.ie>:

> On 24/02/2010 21:42, Christine Penner wrote:
> > This is what I did.
> >
> > set all blank columns to '0' because they were causing errors.
> > alter table T alter column a type integer using a::integer
> >
> > That worked perfectly.
>
> Glad you got sorted.
>
> Bill's advice upthread is worth taking on board - if you're in a
> position to do so, make sure that numbers are stored as numbers rather
> than text, and you'll save yourself all sorts of wacky grief.

As an aside, I feel that this is a natural part of software evolution.
No matter how carefully you try to plan, you end up with someone
saying, "this will be a serial number that will contain both numbers
and letters" ... so you make it a text type field.  Then, a year later
you find out that the serial number is really just a number, and you
actually want to be able to do math on it because you can find out
the year the part was designed by dividing by 1000 or something.

You make the best decisions you can based on the available information.
If you get it wrong, there's always ALTER TABLE :)

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

В списке pgsql-general по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Cast char to number
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Curious plperl behavior