请帮助我理解为什么第二个块抛出错误但是第一个块正在运行.两个地方的限制小于声明的大小(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;
Run Code Online (Sandbox Code Playgroud)
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;
Run Code Online (Sandbox Code Playgroud)
例外:
**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
Run Code Online (Sandbox Code Playgroud)
pax*_*blo 11
参数to extend是要添加到数组的项数,而不是最终大小.
当你在原来的四个中增加三十八个时,你得到了四十二个,这肯定大于41个.好吧,就在我上学的时候,我很确定我会听到这样的变化,如果他们'制定了它:-)
第一个是有效的,因为添加六到四个只能给你十个,远低于四十一个.