请问,是否可以访问可变数组中的单个值?
类似newVariable := myArray(value2)
--> 这会将数组中的第二个值分配给新变量...
我也需要这样的东西:
FOR CYCLE...
x++
newVariable(x) := myArray(value(x))
END FOR CYCLE
是否可以?
Thx,我是信息技术的学生,我正在努力解决这个问题。不知道在哪里看...
根据 oracle 在线文档,varray 类型是 PL/SQL 中用于创建类数组对象的其他集合类型中的类型(我的意思是我们在其他经典编程语言如 C、Java 等中理解的数组)。除了长度可以从 0 变化到其定义期间指定的最大大小。
这是一个例子:
DECLARE
SUBTYPE country_ty IS VARCHAR2(50);
TYPE countries_varr_ty IS VARRAY(10) OF country_ty;
l_varr_countries countries_varr_ty :=
countries_varr_ty
(
'Iran', 'France', 'United Kingdom', 'United States', 'Germany',
'Spain', 'Canada', 'Australia', 'South Africa', 'Afganistan'
);
l_country country_ty;
BEGIN
FOR counter IN l_varr_countries.FIRST .. l_varr_countries.LAST
LOOP
l_country := l_varr_countries(counter);
DBMS_OUTPUT.PUT_LINE('The current value in the array is: '
|| l_country);
END LOOP;
END;
/
有关 varray 的更多信息,您可以参考以下链接:
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#CHDEIJHD
问候,
达里约什