0

I'm writing a query in DB2 and I'm having a little trouble. I have a field that is actually STRING value, but all the values in the data are actually numbers. This is because these are later converted to INT in java and used in another query. I need to modify my query to actually NOT include strings that contain A through Z (so the string the query returns can be converted to an int). What would be the correct AND clause to do this? This needs to be added to a my query and not stored procedure

2 Answers2

0

if your numbers into your zone can contain symbole numeric "," then try this

 select * from yourtable
 where translate(yourzone,  '           ', '0123456789,')=''

else try this

 select * from yourtable
 where translate(yourzone, '          ', '0123456789')=''
Esperento57
  • 16,521
  • 3
  • 39
  • 45
0

if you version of db2 can use regexp_like you can do it:

With "." as decimal symbol

  select *      from yourtable                            
  where REGEXP_LIKE(trim(yourzone) , '^\d+(\.\d*)?$')  

With "," as decimal symbol

  select *      from yourtable                            
  where REGEXP_LIKE(trim(yourzone) , '^\d+(\,\d*)?$')  

Without decimal symbol ( integer only)

  select *      from yourtable                  
  where REGEXP_LIKE(trim(yourzone) , '^\d+$')
Esperento57
  • 16,521
  • 3
  • 39
  • 45