ORA-06532: index out of limit

Help me understand why the second block is throwing an error, but the first block is working. Both places are limited than the declared size (41).

Declare Type typ_int_array IS VARRAY(41) OF NUMBER; v_typ_int_array typ_int_array := typ_int_array(10,20,30,40); BEGIN SYS.DBMS_OUTPUT.PUT_LINE(v_typ_int_array(1)); v_typ_int_array.extend(6); v_typ_int_array(6) := 60; END; 

 Declare Type typ_int_array IS VARRAY(41) OF NUMBER; v_typ_int_array typ_int_array := typ_int_array(10,20,30,40); BEGIN SYS.DBMS_OUTPUT.PUT_LINE(v_typ_int_array(1)); v_typ_int_array.extend(38); v_typ_int_array(38) := 60; END; 

An exception:

 **Error :** Error report - ORA-06532: Subscript outside of limit ORA-06512: at line 6 06532. 00000 - "Subscript outside of limit" *Cause: A subscript was greater than the limit of a varray or non-positive for a varray or nested table. *Action: Check the program logic and increase the varray limit if necessary. 10 
+10
source share
2 answers

The argument for extend is the number of elements to add to the array, not the final size.

When you add thirty-eight to the original four, you get forty-two, which is definitely more than 41. Well, that was when I went to school, but I'm sure I heard about changes like if they accepted it: - )

The first one works because adding six or four gives only ten, well, under the limit forty one.

+11
source

! [enter image description here] (show application)

-1
source

Source: https://habr.com/ru/post/971451/


All Articles