Oracle Database 12c
Function Splitstring (
V\_Input Nvarchar2,
V\_Split\_Pattern In Nvarchar2)
RETURN ret\_Tbl pipelined
Is
v\_string nvarchar2(32767) := v\_input || v\_split\_pattern ;
v\_indexfound NUMBER (5) ;
v\_Index Number (5) := 1;
v\_buff nvarchar2(32767);
BEGIN
LOOP
v\_buff := null ;
v\_indexfound := REGEXP\_INSTR (v\_string, v\_split\_pattern, v\_index) ;
EXIT
WHEN v\_indexfound = 0;
v\_buff := SUBSTR (v\_string, v\_index, v\_indexfound - v\_index) ;
IF (v\_buff IS NOT NULL) THEN
pipe ROW (v\_buff) ;
END IF;
v\_index := v\_indexfound + 1;
END LOOP;
RETURN ;
END Splitstring;
however when i call this function:
select * from Table(fun.Splitstring (v_Input => '1|s,3|4,5,6,7',v_split_pattern => '[|]'));

I am getting [ at 3rd row. why this is being returned or i am passing wrong parameter ??
i have to use regexp_instr for pattern match.