Solved

Oracle SQL - Removing Alphanumeric Characters from Strings

Posted on 2013-11-19
2
1,290 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
[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
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 300 total points
ID: 39659345
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 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 39659359
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

630 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