2014-06-28 15 views
6

Pleae mi aiuta a capire perché il secondo blocco genera un errore, ma il primo blocco è in esecuzione. Il limite di posizionamento è inferiore alla dimensione dichiarata (41).ORA-06532: Sottoscrizione al di fuori del limite

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; 

eccezione:

**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 

risposta

7

L'argomento extend è il numero di elementi da aggiungere alla matrice, non le dimensioni finali.

Quando aggiungi trentotto ai quattro originali, ottieni quarantadue, che è decisamente maggiore di 41. Beh, è ​​stato quando sono andato a scuola ma sono abbastanza certo che avrei sentito parlare di un cambiamento così se lo avessero promulgato :-)

Il primo funziona perché l'aggiunta di sei a quattro ti dà solo dieci, ben al di sotto del limite di quarantuno.

Problemi correlati