check if “it's a number” function in Oracle

后端 未结 16 2757
一整个雨季
一整个雨季 2020-11-28 10:31

I\'m trying to check if a value from a column in an oracle (10g) query is a number in order to compare it. Something like:

select case when ( is_number(myTab         


        
16条回答
  •  無奈伤痛
    2020-11-28 11:06

    You can use the regular expression function 'regexp_like' in ORACLE (10g)as below:

    select case
           when regexp_like(myTable.id, '[[:digit:]]') then
            case
           when myTable.id > 0 then
            'Is a number greater than 0'
           else
            'Is a number less than or equal to 0'
         end else 'it is not a number' end as valuetype
    from table myTable
    

提交回复
热议问题