INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Remove Range of Numbers from a Text String

Remove Range of Numbers from a Text String

(OP)
I have a field that I need to remove a certain range of numbers from, however, this field is VARCHAR2 and can contain letters.

My current code is as follows (in the Where clause): field.field_name not between '27000000' and '27999999'

The problem is this is also taking out records that are not in this range, such as 27000.

What code can I place in the where clause to solve this issue?

Thanks for the help!

RE: Remove Range of Numbers from a Text String

(OP)
Hi, thanks for the response.

The problem with those is that they throw an error when it gets to a record that actually has a letter included. I need to restrict the where clause to only apply to records that are numeric

RE: Remove Range of Numbers from a Text String

That's why johnherman gave you this link to check if your field is numeric.
For the records with letters in them you need some other logic.

Have fun.

---- Andy

RE: Remove Range of Numbers from a Text String

How about this?

CODE

WHERE LPAD(field.field_name,8,'0') NOT BETWEEN '27000000' AND '27999999' 
Note that this will truncate the field to 8 characters, so if field_name is longer than this you should LPAD to that full length:

CODE

WHERE LPAD(field.field_name,10,'0') NOT BETWEEN '0027000000' AND '0027999999' 

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close