【问题标题】:Sybase check if value is numericSybase 检查值是否为数字
【发布时间】:2017-01-25 03:06:53
【问题描述】:

如何检查该值是否为数字? 我试过的是数字,但它返回一个找不到函数的错误。

例子:

select *isnumeric*("abc") // returns 0 or false
select *isnumeric*("123") // returns 1 or true

【问题讨论】:

  • 你认为像“1.2E3”这样的值是数字吗?
  • isnumeric() 受支持,但仅在 ASE 版本 15.0.1 或更高版本中。

标签: stored-procedures sybase isnumeric


【解决方案1】:

一个合理的方法是寻找非数字:

select (case when str like '%[^0-9]%' then 0 else 1 end)

这会查找数字字符串。如果需要,您可以扩展它以支持负号、小数点和指数表示。

【讨论】:

    猜你喜欢
    • 2011-06-28
    • 2013-01-06
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 2017-05-19
    • 2013-05-27
    相关资源
    最近更新 更多