oracle自定义split分割函数
函数如下:
create or replace FUNCTION fn_rme_split(p_str IN VARCHAR2, p_delimiter IN VARCHAR2) RETURN rme_split PIPELINED IS j INT := 0; i INT := 1; len INT := 0; len1 INT := 0; str VARCHAR2(4000); BEGIN len := LENGTH(p_str); len1 := LENGTH(p_delimiter); WHILE j < len LOOP j := INSTR(p_str, p_delimiter, i); IF j = 0 THEN j := len; str := SUBSTR(p_str, i); PIPE ROW(str); IF i >= len THEN EXIT; END IF; ELSE str := SUBSTR(p_str, i, j - i); i := j + len1; PIPE ROW(str); END IF; END LOOP; RETURN; END fn_rme_split;
测试如下:
1 select temp.ass_code 2 from (SELECT COLUMN_VALUE AS ass_code 3 FROM TABLE(rme_delete.fn_rme_split(‘a,b,c,d,e,f ‘,‘,‘))) temp;执行结果如下:
相关推荐
银角大王 2020-06-25
Hhanwen 2020-05-12
zhangll00 2020-05-07
sui 2020-04-29
GeorgeTH 2020-03-02
Aggressivesnail 2020-02-28
laohyx 2020-01-30
清风徐来水波不兴 2020-01-05
sdwylry 2020-01-05
budding0 2019-12-17
iphilo 2019-12-16
jiangtie 2019-12-09
嗡汤圆 2019-11-10
LiHansiyuan 2019-11-03
程松 2019-09-05
上方科技技术交流 2016-07-11
zhoushuaiyin 2015-05-26