2017-08-12 46 views
1

我在運行此代碼的cmd中嘗試了幾次,但每次它在Declare中都聲明第1行的下限超出限制但我沒有發現任何問題 我該怎麼辦?腳標超出限制

This is my cmd and the code is under the image

declare 
    type namesarray is varray(5) of varchar2(10); 
    type grades is varray(5) of integer; 
    names namesarray; 
    marks grades; 
    total integer; 
begin 
    names := namesarray('Pronab','Kavita','Pritam','Ayan','Bpl'); 
    marks := grades(96,96,97,93,92,90); 
    total := names.count; 

    dbms_output.put_line('Total ' || total || 'Students'); 

    for i in 1..total loop 
     dbms_output.put_line('Student: ' || names(i) || 'Marks' || marks(i)); 
    end loop; 
end; 
/

ERROR:

ORA-06532: Subscript outside of limit

ORA-06512: at line 1

回答

1

我相信,這行是問題: -

marks := grades(96,96,97,93,92,90); 

陣列等級被定義爲長度爲5的,但你試圖插入6個元素

+0

非常感謝我現在解決了這個問題,我確切地得到了我的預期結果是線 –