DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: ORA-06531: Reference to uninitialized collection

  1. #1
    Join Date
    Dec 2005
    Posts
    195

    ORA-06531: Reference to uninitialized collection

    All, can you please explain me where i should change to fix this error.

    SQL> create or replace procedure strToken(line IN varchar2, tokenChar IN varchar2
    default ',') is
    2 TYPE tokenTableType is TABLE of varchar2(4000) ;
    3 tokens tokenTableType;
    4 vCnt integer := 1;
    5 myLine varchar2(4000) := null;
    6 vPos integer := 1;
    7 begin
    8 while (vPos <= length(line)) loop
    9 if (length(replace(tokenChar,substr(line, vPos, 1), '')) = length(tokenChar)) then
    10 myLine := myLine || substr(line, vPos, 1);
    11 elsif (myLine is not NULL) then
    12 tokens(vCnt) := myLine;
    13 myLine := null;
    14 vCnt := vCnt + 1;
    15 end if;
    16 vPos := vPos + 1;
    17 end loop;
    18 if (myLine is not NULL) then
    19 tokens(vCnt) := myLine;
    20 end if;
    21 vCnt := 1;
    22 for vCnt in 1..tokens.count() loop
    23 dbms_output.put_line(vCnt||' '||tokens(vCnt));
    24 end loop;
    25 end;
    26 /

    Procedure created.

    Elapsed: 00:00:01.02
    SQL> exec strToken('ADBCERFG,khjf,hjkfhsd, POt',',');
    BEGIN strToken('ADBCERFG,khjf,hjkfhsd, POt',','); END;

    *
    ERROR at line 1:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SCOTT.STRTOKEN", line 12
    ORA-06512: at line 1

  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    try

    tokens tokenTableType := tokenTableType();

  3. #3
    Join Date
    Dec 2005
    Posts
    195
    Thanks. It works now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width