Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pipelined Function Not returning values as expected

Sunil K.Jan 3 2015 — edited Jan 5 2015

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 => '[|]'));

error.PNG

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.

This post has been answered by BluShadow on Jan 5 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2015
Added on Jan 3 2015
3 comments
816 views