Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: formating

Re: formating

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Tue, 19 Jun 2001 21:16:47 +0200
Message-ID: <tiv954rm7iifc0@beta-news.demon.nl>

"Benjamin.Altman" <benjamin.altman_at_noaa.gov> wrote in message news:3B2F8E57.80C0E714_at_noaa.gov...
> If a table has a varchar2 field containing numbers like 1234567890 is
> there any easy way to format it into (123)456-7890 without taking it
> apart and pasting it together with substr etc.?
>
> Thanks,
> Ben
>

As it is a varchar2 column, you can't apply to_char with a format mask to it.
You can try to_char(to_number(<column>),'(999)999-9999') I have just run into a situation where designer choose to use varchar2 for almost all number columns. Obviously that was a stupid choice, as the affected columns have to be left-padded, and are in the primary key. If you can, change your varchar2 into number, before you end up using constructs like the above one virtually *everywhere*

Hth,

Sybrand Bakker, Oracle DBA Received on Tue Jun 19 2001 - 14:16:47 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US