oracle中isnumber函数,Oracle 函数isnumber问题

Oracle中怎么判断一列数据是否为数字类型, 没有isnumber()这样的函数, to_number()的时候又会出错, 想找到是那行数据导致出现to_number()出问题了, 怎么办?

我简单的google了以下, 看到:

简单的SQL:

select aa.rowid, instr(translate(aa.a,

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',

'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X') as IS_A

FROM aa

对于一列中的其他特殊字符就得自己添加到Z后面了,要理解上面SQL的含义先理解几个Oracle函数了:

---------------

translate( string1, string_to_replace, replacement_string )

string1 is the string to replace a sequence of characters with another set of characters.

string_to_replace is the string that will be searched for in string1.

replacement_string - All characters in the string_to_replace will be replaced with the corresponding character in the replacement_string.

Applies To:

* Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

For example:

translate('1tech23', '123', '456);     would return '4tech56'

translate('222tech, '2ec', '3it');     would return '333tith'

---------

instr( string1, string2 [, start_position [, nth_appearance ] ] )

string1 is the string to search.

string2 is the substring to search for in string1.

start_position is the position in string1 where the search will start. This argument is optional. If omitted, it defaults to 1. The first position in the string is 1. If the start_position is negative, the function counts back start_position number of characters from the end of string1 and then searches towards the beginning of string1.

nth_appearance is the nth appearance of string2. This is optional. If omitted, it defaults to 1.

Note:

If string2 is not found in string1, then the instr Oracle function will return 0.

Applies To:

* Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

For example:

instr('Tech on the net', 'e')     would return 2; the first occurrence of 'e'

instr('Tech on the net', 'e', 1, 1)     would return 2; the first occurrence of 'e'

instr('Tech on the net', 'e', 1, 2)     would return 11; the second occurrence of 'e'

instr('Tech on the net', 'e', 1, 3)     would return 14; the third occurrence of 'e'

instr('Tech on the net', 'e', -3, 2)     would return 2.

自己简单的测试了以下:

select to_number('3 3') from dual;

也会出问题了, 就将空格添加到上面的SQL中就可以了。

select aa.rowid, instr(translate(aa.a,

'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ',

'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X') as IS_A

FROM aa

阅读(4107) | 评论(1) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ISNUMBER函数是Excel常用的一个函数,用于判断参数是否为数值。如果参数是数值,则函数返回TRUE;否则返回FALSE。函数的语法结构为=ISNUMBER(value)。其,value是要判断的参数,可以是数字、单元格引用或文本形式的数字串。如果value是纯数字,则返回TRUE,否则返回FALSE。 ISNUMBER函数有以下几个常见用法和实例: 1. 用来判断引用的参数或指定单元格的值是否为数值型数字。比如,可以使用=ISNUMBER(E2)来判断E2单元格的值是否为数值。如果是数值,则返回TRUE,否则返回FALSE。 2. 可以判断引用数字串或文本形式的字符串是否为数值型数字。例如,=ISNUMBER("123")会返回FALSE,因为有引号的数字串被视为文本形式的数字;而=ISNUMBER(123)会返回TRUE,因为123是数值型数字;=ISNUMBER("abc")会返回FALSE,因为它是文本形式的字符串。 3. 可以与IF函数结合使用,用来提取数值。例如,可以使用=IF(ISNUMBER(E2),E2,"-")来获取E列数值型数字的值。如果E2为数值型数字,则返回E2的值;否则返回"-"。 4. 可以与IF、FIND/SEARCH函数结合使用,用于判断字符串是否包含某个元素。例如,可以使用=IF(ISNUMBER(FIND("A",A2)),"有","无")来判断字符串A2是否包含大写字母A。如果包含,则返回"有";否则返回"无"。 5. 可以与SUMPRODUCT函数结合使用,用于统计满足条件的数据个数。例如,可以使用=SUMPRODUCT((A2:A20=A2)*ISNUMBER(C2:C20))来计算一列满足条件的数值型数字的个数。 总之,ISNUMBER函数在Excel用于判断参数是否为数值,可以帮助我们进行数据的分类和统计。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Excel如何使用ISNUMBER函数](https://blog.csdn.net/ffcell2016/article/details/122028772)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Excel的ISNUMBER函数及其用法](https://blog.csdn.net/weixin_50853979/article/details/124057197)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值