Solved

Find a non-numeric character

Posted on 2011-03-04
8
636 Views
Last Modified: 2012-06-27
I want to find if there is any non-numeric character in the column A in table test.

Column A has varchar2(100) as the datatype.

Can someone suggest asap
0
Comment
Question by:d27m11y
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Expert Comment

by:pdd1lan
ID: 35040240
0
 
LVL 2

Accepted Solution

by:
choukssa earned 125 total points
ID: 35040715

 I have a postal_code table that has numeric data stored in varchar2  field. I am using this regular exp  '^[a-zA-Z]*$'  to find if any chars are alpha. You can extend this regex to have special chars also.
SQL>     SELECT postal_code FROM postal_code WHERE REGEXP_LIKE (postal_code, '^[a-zA-Z]*$')
    and postal_code in ('00501','00501','00544','00544','00601','00601','00601','00601','00602');
  2
no rows selected

Open in new window

0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 125 total points
ID: 35041192
>>You can extend this regex to have special chars also.

Wouldn't it be easier to do:  REGEXP_LIKE (col1, '[^0-9]+')


>>and postal_code in ('00501','00501','00544','00544','00601','00601','00601','00601','00602');

FYI:

With that in-list, I can't think of any columns possible that would be non-numeric.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:choukssa
ID: 35041287

With that in-list, I can't think of any columns possible that would be non-numeric.

Yes that is the point. That's why it does not return any rows. I was trying to demonstrate that its a varchar2 field with numeric values.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35041301
>>Yes that is the point.

Cool.  Just making sure.  In my test cases I prefer to show both sides.  Bad rows as well as good rows.
0
 

Author Comment

by:d27m11y
ID: 35058171


 I tried this for my business scenario.  We were expecting the columns are filled with '(' or ')'  or '-'

select
pid,phonenumber,contacttypeid,l.lookupvalue  
from
memberphone mp
,lookup l
WHERE
REGEXP_LIKE(phonenumber, '()-')
and l.lookupid = mp.contacttypeid
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35058342
Finding non-numeric versus finding non-valid phone numbers are two different questions.

Non-numerics can be found with any of the first three posts and answers the question asked.

If you now need to find invalid phone numbers, I suggest you close this question by choosing all or what you consider the best method of findind non-numerics and open a new question and provide more detailed requirements.

You would need to specific ALL the valid masks for a phone number.
0
 

Author Closing Comment

by:d27m11y
ID: 35058478
Thanks for the help and it helped me resolve my issue
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question