Oracle字串拆分批量處理,多行處理

2021-10-06 04:14:29 字數 1413 閱讀 7570

之前想使用regexp_replace,直接處理多行字串拆分,使用以前sql處理:

insert

into yy1 select t.xh,

regexp_substr(t.ssbw,

'[^、]+',1

,level

) ssbw from mm1 t

connect

bylevel

<= length(t.ssbw)

- length(regexp_replace(t.ssbw,

'、','')

)+1

資料只有1471條,但是關聯出來資料很慢,量又多,導致根本無法處理,因此採用過程塊處理,1秒不到就處理完成。

mm1表結構,mm的表結構跟mm1一致:

create

table mm1

( xh varchar2(

100 byte)

,--主鍵

ssbw varchar2(

2000 byte)

--需要拆分的字段

)

yy1表結構

create

table yy1

( xh varchar2(

100 byte)

, ssbw varchar2(

4000 byte)

)

批量處理**塊:

declare

num int

;begin

num :=0;

for num in

1..1471

loop

---迴圈次數 表示從1開始,1471結束

delete mm1;

commit

;insert

into mm1 select

*from mm where to_number(xh)

=num;

commit

;insert

into yy1 select t.xh,

regexp_substr(t.ssbw,

'[^、]+',1

,level

) ssbw from mm1 t

connect

bylevel

<= length(t.ssbw)

- length(regexp_replace(t.ssbw,

'、','')

)+1;

commit

;end

loop

;end

;

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...