DB2- How to check if varchar field value has integers

后端 未结 7 894
借酒劲吻你
借酒劲吻你 2020-12-10 02:58

Is there an inbuilt DB2 function or any query to check if the character i have is a number? (I cannot use user defined functions)

7条回答
  •  执念已碎
    2020-12-10 03:33

    There are many approaches. Take a look at that solution using only two functions:

    CASE
        WHEN REPLACE(TRANSLATE(test_str, '0','123456789','0'),'0','') = ''
        THEN 'All digits'
        ELSE 'Not all digits'
    END
    

    In general - less functions - better performance :)

提交回复
热议问题