clob大字段截取值

来源:互联网 发布:人卫网络增值服务 编辑:程序博客网 时间:2024/04/30 13:08

     oracle字段clob类型值判断可以用dbms_lob.instr(a, 'b', 1, 1) > 0.   

例如:

select notifyid,
       substr(m, instr(m, 'aa', 1, 1) + 87, 18) as aa,
       substr(m, instr(m, 'bb', 1, 1) + 24, 12) as bb,
       substr(m, instr(m, 'property="cc"', 1, 1) + 29, 6) as cc,
       substr(m, instr(m, 'property="dd"', 1, 1) + 29, 13) as dd,
       substr(m, instr(m, 'expiryTime', 1, 1) + 25, 14) as expiretime,
       substr(m, instr(m, 'updateTime', 1, 1) + 25, 14) as updatetime
       from (select to_char(t.data) as m, t.notifyid as notifyid
                    from
                     (select *
                             from t_test t
                             where t.createtime > to_date('20160526000000', 'yyyymmddhh24miss')
                             and dbms_lob.instr(t.data, 'Deletion', 1, 1) > 0 
                             and dbms_lob.instr(t.data, '<int>0</int>', 1, 1) > 0) t) ;



语法: 
instr(sourceString,destString,start,appearPosition) 

instr('源字符串' , '目标字符串' ,'开始位置','第几次出现') 

其中sourceString代表源字符串; 

destString代表要从源字符串中查找的子串; 

start代表查找的开始位置,这个参数可选的,默认为1; 

appearPosition代表想从源字符中查找出第几次出现的destString,这个参数也是可选的, 默认为1 

如果start的值为负数,则代表从右往左进行查找,但是位置数据仍然从左向右计算。 





SUBSTR()函数   
1.用处:是从给定的字符表达式或备注字段中返回一个子字符串。    

2.语法格式:SUBSTR(cExpression,nStartPosition [,nCharactersReturned])    

其中,cExpression指定要从其中返回字符串的字符表达式或备注字段; 

nStartPosition用于指定返回的字符串在字符表达式或备注字段中的位置, 

nCharactersReturned用于指定返回的字符数目,缺省时返回字符表达式的值结束前的全部字符。   

3.举例:STORE'abcdefghijlkm' To mystring    

SUBSTR(mystring ,1,5) 显示 "abcde"  1 从第一个字符开始 截取的字符中,包括第一个字符  

SUBSTR(mystring ,6) 显示 "fghijklm"    

SUBSTR(mystring,-2)显示“km”   最右边一个字符是-1,最右边左边的字符是-2,然后默认是从左向有取剩下的全部的字符 

SUBSTR(mystrng,-4)显示“jlkm” 

0 0
原创粉丝点击