If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Is numeric???

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-19-11, 12:46
kristo5747 kristo5747 is offline
Registered User
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 12
Is numeric???

The vendor data we load in our staging table is rather dirty. One column in particular captures number data but 40% of the time has garbage characters or random strings.

I have to create a report that filters out value ranges in that column. So, I tried playing with a combination of replace/translate like so

Code:
select replace(translate(upper(str),' ','all possible char'),' ','')
from table
but it fails whenever it encounters a char I did not code. Therefore, the report can never be automated.

Javascript has the isNaN() function to determine whether a value is an illegal number (True if it is and false if not).

How can I do the same thing with DB2?? Do you have any idea?

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 12-19-11, 13:29
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Wouldn't it be easier to identify numbers instead of not-a-numbers? After all, there are only 10 possible decimal digits.
Reply With Quote
  #3 (permalink)  
Old 12-19-11, 14:25
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
It is tougher to validate numbers than you might think. Consider -5.38e+6 which is a perfectly valid real number.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On