| 
                         一:理论 
oracle 截取字符(substr),检索字符位置(instr) case when then else end语句使用 收藏 
常用函数:substr和instr 
1.SUBSTR(string,start_position,[length]) 求子字符串,返回字符串 
解释:string 元字符串 
start_position 开始位置(从0开始) 
length 可选项,子字符串的个数 
For example: 
2.INSTR(string,subString,position,ocurrence)查找字符串位置 
解释:string:源字符串 
subString:要查找的子字符串 
position:查找的开始位置 
ocurrence:源字符串中第几次出现的子字符串 
For example: 
INSTR('CORPORATE FLOOR','OR',3,2)中,源字符串为'CORPORATE FLOOR',目标字符串为'OR',起始位置为3,取第2个匹配项的位置;返回结果为 14 ' 
二:实际测试 
<div class="jb51code"> 
<pre class="brush:sql;"> 
select substr('OR:com.lcs.wc.placeholder.Placeholder:860825',INSTR('OR:com.lcs.wc.placeholder.Placeholder:860825',':',1,2)+1,length('OR:com.lcs.wc.placeholder.Placeholder:860825')),2),length('OR:com.lcs.wc.placeholder.Placeholder:860825') From dual; 
测试成功                         (编辑:莱芜站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |