title: custom split function not working in pl/sql
body: <p>I have written a custom function in pl/sql which splits a clob variable into set of strings on the basis of the separator provided but it is not working as intended please help me out in figuring the problem with the code.</p>
  
  <pre><code>create or replace 
  FUNCTION                             SPLITCLOB (p_in_string clob, p_delim VARCHAR2) RETURN t_array
  IS
    i       number :=0;
    pos     number :=0;
    lv_str  clob := p_in_string;
  
    Strings t_array:=t_array ();
  Begin
    -- determine first chuck of string
    pos := DBMS_LOB.INSTR(lv_str,p_delim,1,1);
  
    If ( pos = 0) Then
      i := i + 1;
      strings.Extend();
      strings(i) := DBMS_LOB.SUBSTR(lv_str,1);
       RETURN strings;
    End If;
    -- while there are chunks left, loop
    WHILE ( pos != 0) LOOP
       -- increment counter
       i := i + 1;
  
       -- create array element for chuck of string
       strings.EXTEND();
       strings(i) := DBMS_LOB.SUBSTR(lv_str,1,pos-1);
  
       -- remove chunk from string
       lv_str := DBMS_LOB.SUBSTR(lv_str,pos+1,dbms_lob.getLength(lv_str));
  
       -- determine next chunk
       pos := DBMS_LOB.INSTR(lv_str,p_delim,1,1);
  
       -- no last chunk, add to array
       IF pos = 0 THEN
          strings.extend();
          strings(i+1) := lv_str;
       END IF;
    End Loop;
  
    -- return array
    RETURN strings;
  End Splitclob;
  </code></pre>
  
  <p>here <code>t_array()</code> is custom type defiition of which is provided below</p>
  
  <pre><code>create or replace 
    TYPE "T_ARRAY" 
    AS TABLE OF VARCHAR2(500);
  </code></pre>
  
  <p>thanks in advance</p>