对某一个字段进行to_number处理时,因为部分数据中包含字母,所以报错
ORA-01722: 无效数字
这样就需要先除去字母以及字母后面的字符
--处理不含有字母的数据
update a_organ set code_new=code_old where regexp_instr(code_old,'[a-z]')=0;
--处理包含字母的数据
update a_organ set code_new=substr(code_old,1,regexp_instr(code_old,'[a-z]')-1)
where regexp_instr(code_old,'[a-z]')>0;
regexp_count()是统计字符串中包含某个字符串的个数
select regexp_count('111111','1') from dual;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28803801/viewspace-769438/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28803801/viewspace-769438/