3 Replies Latest reply: Mar 15, 2012 12:29 AM by HamidHelal RSS

    Error in the procedure

    920376
      HI
      Could anyone help me what's wrong with this procedure.Thanks in advance.
      CREATE OR REPLACE
      PACKAGE BODY CUSTOMER_SEARCH_PKG AS

      FUNCTION F_string_splits ( v_querystring VARCHAR2, v_delim VARCHAR2) RETURN V_STRING_PARSER_ARRAY AS

      i number :=0;
      pos number :=0;
      f_string varchar2(50) := v_querystring;

      strings V_STRING_PARSER_ARRAY ;
      BEGIN
      /* TODO implementation required */
      -- determine first chuck of string
      pos := instr(f_string,v_delim,1,1);

      -- while there are chunks left, loop
      WHILE ( pos != 0) LOOP

      -- increment counter
      i := i + 1;

      -- create array element for chuck of string
      strings(i) := substr(f_string,1,pos-1);

      -- remove chunk from string
      f_string := substr(f_string,pos+1,length(f_string));

      -- determine next chunk
      pos := instr(f_string,v_delim,1,1);

      -- no last chunk, add to array
      IF pos = 0 THEN

      strings(i+1) := f_string;

      END IF;

      END LOOP;
      RETURN strings;
      END F_string_splits;

      procedure sp_string_splits(
      v_querystring IN varchar2(20),
      v_string out V_STRING_PARSER_ARRAY
      ) AS
      BEGIN

      v_querystring := 'CUST_ID:102893|EMAIL:tst@ffn.com|FIRST_NAME:chris|LAST_NAME:west';
      v_string := F_string_splits(v_querystring,';');
      for i in 1 .. v_string.count loop
      dbms_output.put_line(v_string(i));
      end loop;

      END sp_string_splits;

      END CUSTOMER_SEARCH_PKG;