Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Subscript beyond count when initializing varray

jerry44May 25 2015 — edited May 26 2015

Following code:

declare

cnt number(1) :=1;

cursor c_cur is

select COUNTRY_NAME from countries where rownum <3;

type arr_name is varray(5) of VARCHAR2(40);

arr_cn arr_name :=arr_name();

begin

open c_cur;

loop

fetch c_cur into arr_cn(cnt);

exit when c_cur%notfound;

cnt := cnt+1;

end loop;

close c_cur;

end;

Caused error:

Error report -

ORA-06533: Subscript beyond count

ORA-06512: at line 10

06533. 00000 -  "Subscript beyond count"

*Cause:    An in-limit subscript was greater than the count of a varray

           or too large for a nested table.

*Action:   Check the program logic and explicitly extend if necessary.

I do not understand why, could someboy explain it?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2015
Added on May 25 2015
4 comments
2,379 views