20. orcle中统计一个字符串中某个字符的长度

Posted on 2014-12-29 15:45  zkx4213  阅读(237)  评论(0编辑  收藏  举报

例子1:统计一个字符串中“,”的个数:

select lengthb(regexp_replace('[a,b,c,d,e,f]','[^,]',null))  as res from dual;

例子2:查询lborganization表中字段fdncode包含1个"."号的所有记录:
select * from lborganization a where lengthb(regexp_replace('['||a.fdncode||']','[^.]',null)) =1;

例子3:把lborganization表中字段fdncode包含4个"."号的所有记录中的grade改为4:

update lborganization a set a.grade = 4 where lengthb(regexp_replace('['||a.fdncode||']','[^.]',null)) =4;

 

Copyright © 2024 zkx4213
Powered by .NET 8.0 on Kubernetes