Loading...

Friday, January 04, 2008

ORA-06533: Subscript beyond count

This error is easily explained with the help of a few examples:
DECLARE
TYPE array_type IS VARRAY(10) OF VARCHAR2(200);
my_array array_type := array_type(null, null, null);
BEGIN
my_array(1) := 'a';
my_array(2) := 'b';
my_array(3) := 'c';
my_array(4) := 'd';
dbms_output.enable;
dbms_output.put_line(my_array.COUNT);
END;

Error report:
ORA-06533: Subscript beyond count
ORA-06512: at line 8
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.

my_array has been initialized with three elements (out of a maximum of 10), but at line 8 we are trying to set the value of a fourth element.
You cannot set a non-existent varray or table element if you haven't properly initialized the varray as shown in a previous posting.

Another typical situation involves nested tables:
DECLARE
TYPE table_type IS TABLE OF VARCHAR2(200);
my_table table_type := table_type();
BEGIN
my_table.EXTEND(5);
my_table.TRIM(5);
my_table(3) := 'c';
dbms_output.enable;
dbms_output.put_line('total:'||my_table.COUNT);
END;

Error report:
ORA-06533: Subscript beyond count
ORA-06512: at line 7
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.
By trimming 5 elements starting from the end of a collection consisting of 5 elements, you are shrinking its size to zero and as a consequence you cannot set the third element to a value, because it's like having unitialized all the elements.

Unfortunately DELETE and TRIM can easily lead to some degree of confusion, because their behavior is not so consistent as it could be:

DECLARE
TYPE table_type IS TABLE OF VARCHAR2(200);
my_table table_type := table_type();
BEGIN
my_table.EXTEND(5);
my_table.DELETE(1,5);
my_table(3) := 'c';
dbms_output.enable;
dbms_output.put_line('total:'||my_table.COUNT);
dbms_output.put_line('last subscript:'||my_table.LAST);
dbms_output.put_line('first subscript:'||my_table.FIRST);
END;

total:1
last subscript:3
first subscript:3
However, if instead of selectively deleting the elements from 1 to 5, you omit the parameters altogether:
DECLARE
TYPE table_type IS TABLE OF VARCHAR2(200);
my_table table_type := table_type();
BEGIN
my_table.EXTEND(5);
my_table.DELETE;
my_table(3) := 'a';
dbms_output.enable;
dbms_output.put_line('total:'||my_table.COUNT);
dbms_output.put_line('last subscript:'||my_table.LAST);
dbms_output.put_line('first subscript:'||my_table.FIRST);
END;

Error report:
ORA-06533: Subscript beyond count
ORA-06512: at line 7
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.
This happens because the DELETE method without arguments physically removes the collection elements, whereas DELETE(m,n) or DELETE(n) simply erase the contents, making the element null.

See more examples and situations involving DELETE, TRIM and related errors.
-----------------------------------
ORA-06533: Indice inferiore oltre il conteggio
ORA-06533: Subíndice mayor que el recuento
ORA-06533: Subscript més enllà del comptador
ORA-06533: Valeur de l'indice trop grande
ORA-06533: Index oberhalb der Grenze
ORA-06533: Δείκτης εκτός μέτρησης τιμών
ORA-06533: Subscript uden for antal
ORA-06533: Indexvariabel större än faktiskt antal
ORA-06533: Subskript over antall
ORA-06533: Alikomento ylitti määrän
ORA-06533: Számlálón kívüli index érték
ORA-06533: Indicele este mai mare decât dimensiunea tabloului
ORA-06533: Subscript is te hoog.
ORA-06533: Subscrito acima da contagem
ORA-06533: Subscrito para além da contagem
ORA-06533: Индекс выходит за пределы счетчика массива
ORA-06533: Dolní index přesahuje čítač
ORA-06533: Dolný index presahuje počet
ORA-06533: Indeks (współrzędna elementu tablicy) przekracza licznik
ORA-06533: İndis sayımın ötesinde
ORA-06533: Subscript beyond count

See message translations for ORA-06533 and search additional resources

No comments:

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles