RE: Remove non-integer Characters from a column

  • From: "Patterson, Joel" <jpatterson@xxxxxxxxxx>
  • To: "oratips@xxxxxxxxx" <oratips@xxxxxxxxx>, oracle-l <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 16 Jan 2014 11:29:38 -0500

I agree that regexp_replace would be the way to go.  You could also combine 
translate and replace.  For an idea of that:

You translate all the non-numeric to 'z', or spaces.  (or null? Since there 
will be spaces in the middle).

select data,
[ to_number( ]    replace(translate(lower(data), 'abc...xyz','...

Rpad, lpad could come into play.  Start with translate function, and work out 
from there.

Joel Patterson
Database Administrator
904 928-2790

From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Bala
Sent: Thursday, January 16, 2014 10:39 AM
To: oracle-l
Subject: Remove non-integer Characters from a column

Gurus,

Oracle 11..2.0.3 on Linux R6
==
1) I have a field with a data type of varchar2 that has integers and 
non-integer characters.
2) Example: 214' or 61+45 or 88/8.
3) How can i remove the non-integer characters from the table ?
4) Can a function be written to remove non-integer characters ?, so in the 
example it would be 214 or 6145 or 888
==

Appreciate any pointers to solve this, thank you in advance.

Sincerely

--
Bala Rao

--
Joel Patterson
Sr. Database Administrator | Enterprise Integration
Phone: 904-928-2790 | Fax: 904-733-4916
www.entint.com<http://www.entint.com/>

[http://i1202.photobucket.com/albums/bb367/Entint/signaturev61.jpg]<http://www.entint.com/>

[http://i1202.photobucket.com/albums/bb367/Entint/th_FaceBook1.jpg]<http://www.facebook.com/pages/Enterprise-Integration/212351215444231>
  [http://i1202.photobucket.com/albums/bb367/Entint/th_Twitter1.jpg] 
<http://twitter.com/#!/entint>   
[http://i1202.photobucket.com/albums/bb367/Entint/th_LinkedIn1.jpg] 
<http://www.linkedin.com/company/18276?trk=tyah>   
[http://i1202.photobucket.com/albums/bb367/Entint/th_YouTube1.jpg] 
<http://www.youtube.com/user/ValueofIT>

This message (and any associated files) is intended only for the use
of the addressee and may contain information that is confidential,
subject to copyright or constitutes a trade secret. If you are not the
intended recipient, you are hereby notified that any dissemination,
copying or distribution of this message, or files associated with this
message, is strictly prohibited. If you have received this message in
error, please notify us immediately by replying to the message and
deleting it from your computer. Messages sent to and from us may be
monitored. Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company. [v.1.1]

Other related posts: