Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Excluding Numeric and Alphanumeric in SQL

LazarJul 17 2018 — edited Jul 19 2019

Hi,

DB version : 12C

I have a scenario to exclude and to pull out invalid values present in the database. please Assist.

Valid Data samples;-

SlnoValid Data
1b***********3
2****************
3Michael
45*********b
5(NULL)

CREATE TABLE TEST_NAME(FIRST_NAME VARCHAR2(100),MIDDLE_NAME VARCHAR2(100),LAST_NAME VARCHAR2(100))

/

insert into TEST_NAME VALUES('E*******************C','','B*********M');

insert into TEST_NAME VALUES('宏*******司','','');

insert into TEST_NAME VALUES('N/A','','');

insert into TEST_NAME  VALUES('99','','DAVID');

insert into TEST_NAME VALUES('LANGLEVELDT','','');

insert into TEST_NAME VALUES('宏司','宏司','宏司');

insert into TEST_NAME VALUES('.','..','');

insert into TEST_NAME VALUES('NA','','');

insert into TEST_NAME VALUES('..','','');

insert into TEST_NAME VALUES('4','','Z****N');

insert into TEST_NAME VALUES('CLINTON4','','');

insert into TEST_NAME VALUES('BILL.','','');

insert into TEST_NAME VALUES('M*****B','','3');

insert into TEST_NAME VALUES('-','','');

insert into TEST_NAME VALUES('45787CLINTON','','');

COMMIT;

/

--SQL QUERY:-

select first_name,middle_name,last_name

from test_name

where  (regexp_like(first_name, '^([[:digit:]]+$)|([^[:alnum:]]+)$')

     or regexp_like(middle_name, '^([[:digit:]]+$)|([^[:alnum:]]+)$')

     or regexp_like(last_name, '^([[:digit:]]+$)|([^[:alnum:]]+)$'))

/

Desired Output:-

First_nameMiddle_nameLast_name
N/A
99DAVID
...
NA
..
4Z****N
M*****B3
-
This post has been answered by Etbin on Jul 18 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2018
Added on Jul 17 2018
17 comments
1,575 views