Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Subscript beyond count ERROR WHILE INSERTING IN A COLLECTION

Re: Subscript beyond count ERROR WHILE INSERTING IN A COLLECTION

From: Thomas Kyte <tkyte_at_oracle.com>
Date: 20 Dec 2004 14:09:26 -0800
Message-ID: <113580566.0000e99c.086@drn.newsguy.com>


In article <1103575412.682308.53260_at_c13g2000cwb.googlegroups.com>, testmirora_at_hotmail.com says...
>
>Hi,
>
>COULD ANYBODY HELP ME UNDERSTAND THIS ERROR PLEASE,
>
>I'm trying to initialize a collection ALREADY DEFINE.
>
>DESC SEARCH_X;
>
>SEARCH_X TABLE OF SEARCH_P_TYPE
>Name Null? Type
>------------------------- -------- --------
>ID VARCHAR2(10)
>VALUE VARCHAR2(90)
>
>and then I ADD SOME VALUES TO THE SEARCH_X:
>
>DECLARE
>
>c_tab SEARCH_X := SEARCH_X();
>c_count number (5);
>
>BEGIN
>c_tab(1).ID := '100000';
>c_tab(1).VALUE := 'TRYING TO TEST ';
>c_count := c_tab.count;
>DBMS_OUTPUT.PUT_LINE('C_COUNT VALUE IS ' || TO_CHAR(c_count));
>END;
>/
>
>AND I GET THIS ERROR :
>ERROR at line 1:
>ORA-06533: Subscript beyond count
>ORA-06512: at line 7
>
>WHAT COULD BE BEYOND COUNT HERE AS THE STRING'SIZE RESPECT THE
>DECLARATION ?
>
>THANK YOU ALL.
>

http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#14218

you need to "extend" the collection -- you set it up "empty" -- with zero elements.

>DECLARE
>
>c_tab SEARCH_X := SEARCH_X();
>c_count number (5);
>
>BEGIN
c_tab.extend;

>c_tab(1).ID := '100000';
>c_tab(1).VALUE := 'TRYING TO TEST ';

that would work.

-- 
Thomas Kyte
Oracle Public Sector
http://asktom.oracle.com/
opinions are my own and may not reflect those of Oracle Corporation
Received on Mon Dec 20 2004 - 16:09:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US