樣例sql:
select gro.*,
regexp_substr(group_name, '[^/]+', 1, 1) as one_group,
regexp_substr(group_name, '[^/]+', 1, 2) as two_group,
regexp_substr(group_name, '[^/]+', 1, 3) as three_group,
cfg.address as address
left join (select dbms_lob.substr(wm_concat(office.address)) address,
grop.id
where office.id in
(select regexp_substr(grop.work_address_id,
'[^,]+',
1,rownum)
from dual
connect by rownum <=
length(grop.work_address_id) -
length(replace(grop.work_address_id, ',')) + 1)
group by grop.id) cfg on cfg.id = gro.id
最內層的sql作用為根據將組合id拆分成id的乙個集合,可以使用in關鍵字進行處理;
首先以正則進行字串擷取,因為regexp_substr的第4個引數為分隔組的第幾位,由於是不確定的,所以後面通過connect by 來限制分隔組有幾個,通過字串的長度,去掉分隔符,獲取長度大小。
倒數第二層則通過wm_concat函式進行合併,dbms_lob.substr函式將clob轉換成varchar.
最外一層則為關聯
Oracle 拆分字串
create or replace function splitstr p string in varchar2,p delimiter in varchar2 return str split pipelined as v length number length p string v start...
oracle拆分字串
create or replace type array string is table of varchar2 2000 create or replace function f split string 拆分字串 author zhaohuihua i src in varchar2,待拆分的字...
oracle拆分字串
procedure hand mid sys bpm use role iorgtype in bpm compsite user.orgtype type,idate in date is v orgtype bpm compsite user.orgtype type iorgtype v id...