Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 23rd, 2004, 03:27 PM
illig illig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: NYC
Posts: 23 illig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 58 m 37 sec
Reputation Power: 0
Send a message via AIM to illig
Help with delete statement (all non letter/number entries)

I need to delete all rows from a table in which a certain column contains characters other than letters/numbers/ or a period

So ABC. AB12 .124 would be allowed, but ABC^ or ABC/$ would get deleted

This is an Oracle 9i database which AFAIK doesn't support regular expressions, and I'm obviously not that good at SQL

Any help would be appreciated.

Reply With Quote
  #2  
Old November 23rd, 2004, 04:25 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 20 m 49 sec
Reputation Power: 48
Try the translate(field,if, then) function, it turns translates characters by position in
"if" clause into whatever is in the same position in the "then" clause.
Code:
delete from mytable
where 
 to_number(translate(fld1,
          'ABCDEFGHIJKLMNOPQRSTUVWXYZ.~`!@#$%^&*()_+=_|\}]{[":;?/>, ',
          '000000000000000000000000000111111111111111111111111111111') > 0;


Any of the characters that get a '1' cause the row to be deleted.
Test this out first! -- use rollback to undo the delete.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Help with delete statement (all non letter/number entries)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT