Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Oracle Query

Oracle Query

Scheduled Pinned Locked Moved Database
helpdatabaseoraclequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandhya14
    wrote on last edited by
    #1

    Hi all, I have a problem with executing function in Oracle 10g. Below mentioned is the function :- FUNCTION UnpackArray ( Source IN VARCHAR2 DEFAULT NULL, Delimiter IN CHAR DEFAULT ',' ) RETURN reSourceArray0 PIPELINED IS SourceArray00 SourceArray0:=SourceArray0(NULL); TYPE REFCURSOR IS REF CURSOR; CURSOR0 REFCURSOR; DelLen int; Pos int; Cnt int; str int; LEN int; Holder VARCHAR2(255); BEGIN IF Source is null or Delimiter is null THEN Return; END IF; IF RTRIM(LTRIM(Source)) = ' ' THEN Return; END IF; SELECT LENGTH(RTRIM(Delimiter)) INTO DelLen FROM DUAL; SELECT INSTR(UPPER(Source), UPPER(Delimiter)) INTO Pos FROM DUAL; IF Pos = 0 THEN BEGIN INSERT INTO UnpackArray_TBL ( Data ) VALUES ( Source ); return; OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END; END IF; SELECT 1 INTO str FROM DUAL; << LABEL4 >> WHILE Pos > 0 LOOP BEGIN SELECT Pos - str INTO len FROM DUAL; SELECT SUBSTR(Source, str, len) INTO Holder FROM DUAL; INSERT INTO UnpackArray_TBL VALUES ( Holder ); SELECT Pos + DelLen INTO str FROM DUAL; SELECT INSTR(UPPER(Source), UPPER(Delimiter), str) INTO Pos FROM DUAL; OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END; END LOOP; SELECT SUBSTR(Source, str, length(RTRIM(Source))) INTO Holder FROM DUAL; IF length(RTRIM(Holder)) > 0 THEN INSERT INTO UnpackArray_TBL VALUES ( Holder ); OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END IF; Return; LOOP FETCH CURSOR0 INTO SourceArray00.Data; EXIT WHEN CURSOR0%NOTFOUND; PIPE ROW(SourceArray00); END LOOP; CLOSE CURSOR0; RETURN; END; While executing this am getting the error like: Running "EDOCS"."UNPACKARRAY" ( SOURCE = admin, DELIMITER = ). Parameter 'RETURN_VALUE': No size set for variable length data type: String. can anybody help me to solve this...? Thanks in advance.

    S 1 Reply Last reply
    0
    • S sandhya14

      Hi all, I have a problem with executing function in Oracle 10g. Below mentioned is the function :- FUNCTION UnpackArray ( Source IN VARCHAR2 DEFAULT NULL, Delimiter IN CHAR DEFAULT ',' ) RETURN reSourceArray0 PIPELINED IS SourceArray00 SourceArray0:=SourceArray0(NULL); TYPE REFCURSOR IS REF CURSOR; CURSOR0 REFCURSOR; DelLen int; Pos int; Cnt int; str int; LEN int; Holder VARCHAR2(255); BEGIN IF Source is null or Delimiter is null THEN Return; END IF; IF RTRIM(LTRIM(Source)) = ' ' THEN Return; END IF; SELECT LENGTH(RTRIM(Delimiter)) INTO DelLen FROM DUAL; SELECT INSTR(UPPER(Source), UPPER(Delimiter)) INTO Pos FROM DUAL; IF Pos = 0 THEN BEGIN INSERT INTO UnpackArray_TBL ( Data ) VALUES ( Source ); return; OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END; END IF; SELECT 1 INTO str FROM DUAL; << LABEL4 >> WHILE Pos > 0 LOOP BEGIN SELECT Pos - str INTO len FROM DUAL; SELECT SUBSTR(Source, str, len) INTO Holder FROM DUAL; INSERT INTO UnpackArray_TBL VALUES ( Holder ); SELECT Pos + DelLen INTO str FROM DUAL; SELECT INSTR(UPPER(Source), UPPER(Delimiter), str) INTO Pos FROM DUAL; OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END; END LOOP; SELECT SUBSTR(Source, str, length(RTRIM(Source))) INTO Holder FROM DUAL; IF length(RTRIM(Holder)) > 0 THEN INSERT INTO UnpackArray_TBL VALUES ( Holder ); OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL; END IF; Return; LOOP FETCH CURSOR0 INTO SourceArray00.Data; EXIT WHEN CURSOR0%NOTFOUND; PIPE ROW(SourceArray00); END LOOP; CLOSE CURSOR0; RETURN; END; While executing this am getting the error like: Running "EDOCS"."UNPACKARRAY" ( SOURCE = admin, DELIMITER = ). Parameter 'RETURN_VALUE': No size set for variable length data type: String. can anybody help me to solve this...? Thanks in advance.

      S Offline
      S Offline
      sumithz
      wrote on last edited by
      #2

      step 1 : create a Table types named "DIVISION_ARRAY" CREATE TYPE "DIVISION_ARRAY" AS TABLE OF VARCHAR2(12) step 2 : execute the below procedures CREATE OR REPLACE FUNCTION "UNPACKDIVISIONARRAY" (Source IN VARCHAR2 DEFAULT NULL, Delimiter IN CHAR DEFAULT ',') RETURN division_array PIPELINED IS l_list varchar2(32767) := Source; l_idx pls_integer; l_value varchar2(32767); BEGIN loop l_idx := instr(l_list,Delimiter); if l_idx > 0 then pipe row(substr(l_list,1,l_idx-1)); l_list := substr(l_list,l_idx+length(Delimiter)); else pipe row(l_list); exit; end if; end loop; return; end UNPACKDIVISIONARRAY; step 3 : execute the below sql to see the result Select column_value from TABLE(UNPACKDIVISIONARRAY('111,113')) hope that this will help you. regards, Sumith Koshy Thankan, OASYS Information Technology. Dubai

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups