日期:2014-05-17 浏览次数:21150 次
SQL> select * from a2;
ID
------------------------------
01,02,03,04
SQL> select * from a3;
COL1 COL2
---------- ----------
03 cc
04 cc
01 aa
02 bb
SQL> select tid, col1, col2
2 from a3,
3 (select distinct regexp_substr(id, '[^,]+', 1, level) tid from a2
4 connect by level <= length(id) - length(replace(id, ',', '')) + 1)
5 where tid = col1;
TID COL1 COL2
---------- ---------- ----------
03 03 cc
04 04 cc
01 01 aa
02 02 bb
CREATE OR REPLACE FUNCTION split(p_str IN VARCHAR2,
p_delimiter IN VARCHAR2)
RETURN tbl_split IS
j INT := 0;
i INT := 1;
len INT := 0;
len1 INT := 0;
str VARCHAR2(4000);
str_split tbl_split := tbl_split();
BEGIN
IF p_delimiter is not null THEN
len := LENGTH(p_str);
len1 := LENGTH(p_delimiter);
WHILE j < len LOOP
j := INSTR(p_str, p_delimiter, i);
IF j = 0 THEN
j &n