Solved

Oracle SQL - Removing Alphanumeric Characters from Strings

Posted on 2013-11-19
2
1,157 Views
Last Modified: 2013-11-19
Hi,

I'm trying to search in my name field for the records with no alphanumeric values.
I want to find the records with only null value or only special characters such as . , ? ! * % #.

For example,

ID       Name
----     ----------
1         James Brown??..
2
3         ...
4        >,*..??
5        1/James Brown***

Then, I want my code to return only ID 2,3,4 and not 1,5.
Also, I need to put this check in a case statement, rather than in a where clause.

Can you please help me how I can write this check using regexp_like or regexp_replace?

Thank you!
0
Comment
Question by:iamnamja
2 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 300 total points
Comment Utility
Try this:

drop table tab1 purge;
create table tab1 ( id number, col1 varchar2(100));

insert into tab1 values(1,'James Brown??..');
insert into tab1 values(2, null);
insert into tab1 values(3,'...');
insert into tab1 values(4,'>,*..??');
insert into tab1 values(5,'1/James Brown***');
commit;

select id from tab1 where not regexp_like(col1,'[A-Za-z0-9]') or col1 is null;

Open in new window

0
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
Comment Utility
select id from your_table where regexp_like(name,'^[.,?!*%#]+$') or name is null;

simply add whatever characters you want into the [] list
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now