oracle 函数isnumber问题-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 3977126
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2008-01-31 18:21:32

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
阅读(5739) | 评论(1) | 转发(0) |
0

上一篇:近来的小总结

下一篇:滚动新闻!!!

给主人留下些什么吧!~~

chinaunix网友2008-11-27 14:32:23

very good.

|
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图