Re: Casting from varchar to numeric

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Casting from varchar to numeric
Дата
Msg-id web-1461767@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Casting from varchar to numeric  (Tom Ansley <tansley@law.du.edu>)
Список pgsql-novice
Tom,

> Is there a way of casting from a varchar to a numeric type?
>
> My problem consists of a varchar(10) that are all numeric.  They are
> telephone
> numbers and I want to convert them during a select statement to (XXX)
>
> XXX-XXXX
>
> Anybody have any ideas?

Well, first off, you need to know the PostgreSQL conversion functions.
 See the online documentation:  Functions and Operators --> Formatting
Functions.

Second, if you check Roberto Mello's PL/pgSQL cookbook, you'll notice
that I posted a set of functions which auto-format phone numbers to US
spec.
http://www.brasileiro.net/postgres/cookbook/

It's under "String Manipulation Functions".

-Josh Berkus

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

Предыдущее
От: "Adam Erickson"
Дата:
Сообщение: Re: Answering my own question
Следующее
От: gerry.smit@lombard.ca
Дата:
Сообщение: Re: Answering my own question