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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Format phone number

RE: Format phone number

From: Sarnowski, Chris <csarnows_at_CuraGen.com>
Date: Wed, 14 May 2003 11:46:51 -0800
Message-ID: <F001.00598B4F.20030514114651@fatcity.com>

given various list delays, I'm probably 6th or 7th with the answer, but here goes...

select '(' || substr(phone_number,1,3) || ')' || substr(phone_number,4,3) || '-' || substr(phone_number,7,4) from phone_numbers;

Watch for typos - I tested it but not on the same machine, so I had to retype it.

> -----Original Message-----
> From: Bob Metelsky [mailto:bmetelsky_at_cps92.com]
> Sent: Wednesday, May 14, 2003 12:22 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Format phone number
>
>
> All
>
> Say I have a phone number char column with a length of 10 phone
> # is 2129779898
>
> I want to create a view with the number displayed (212)977-9898
>
> Something like
>
> select to_char(phone_number, '(999)999-9999') from phone_numbers;
> ORA-01481: invalid number format model
>
> But obiviously the to_char donst behave as a universial formatting /
> mask function.
> The function seems to, to_char only dates and currency
>
> I've searched google and orafaq but nothing jumped out.
>
> I know someone on this list has the answer...
>
> Thanks!
> bob
>

LEGAL NOTICE:
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this e-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Sarnowski, Chris
  INET: csarnows_at_CuraGen.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed May 14 2003 - 14:46:51 CDT

Original text of this message

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