1. substr()函数和instr()函数
表中一个字段中存了多个值,每个值用逗号分隔,如:‘1,2’代表‘红,黄’,‘5,10’代表‘黑,白’
--截取逗号前的值
substr(a.str, 0, instr(a.str, ',')-1)
--截取逗号后的值
substr(a.str, instr(a.str, ',' , -1, 1)+1, length(a.str))
2. 其他
之前遭遇一个10g版本的Oracle,Oracle 10g是没有wm_concat()函数的,截取后如何进行合并呢?
left join (
select b.openaccountid,b.dvpname,(select rtrim(xmlagg(xmlparse(content a.name||',' wellformed)).getstringval(),',')
from sirm_enum a where a.catalog = 'PLM' and a.type = 'reserveseal' and a.value in (
select regexp_substr((b.reserveseal),'[^,]+',1,level) from dual
connect by level<=length((b.reserveseal)) - length(replace((b.reserveseal),',',''))+1
)) bs from plm_openaccountinfo b
) t9 on t2.objid = t9.openaccountid
本文介绍了在Oracle数据库中使用substr()和instr()函数截取特定字段值的方法,并提供了一个复杂的示例来展示如何处理多个值并进行合并。

51

被折叠的 条评论
为什么被折叠?



