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: Conversion of a varchar2 to a number

RE: Conversion of a varchar2 to a number

From: <Yosi_at_comhill.com>
Date: Wed, 13 Dec 2000 16:22:39 -0500
Message-Id: <10709.124502@fatcity.com>


Dave,

I inherited phone number fields where some of the records had chars in them and some did not (some were entered with '()' and '-', others were just numeric.

It was easy enough to create a function I called stripchars (str1, str2) which strips all occurences of any char in str2 out of str1. It may be faster to actually do a to_number and handle exceptions, I don't know. However, I've since found plenty of uses for the stripchars function.

If you want it I can send it to you.

Yosi

> -----Original Message-----
> From: David Turner [mailto:turner_at_elvis.mu.org]
> Sent: Wednesday, December 13, 2000 1:46 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Conversion of a varchar2 to a number
>
>
> I have a user that has a phone number field that is stored as
> a varchar2 and some of the data actually has letters in it. When
> he tries to do a TO_NUMBER it fails of course on the records that
> have letters in them.
>
> To perform the conversion I thought using a cursor and handling the
> exceptions would work, but wanted to see if other people had a better
> way of doing this.
>
> Thanks, Dave Turner
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: David Turner
> INET: turner_at_elvis.mu.org
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> 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 Dec 13 2000 - 15:22:39 CST

Original text of this message

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