一维数组示例如下:
-- Created on 2014-5-15 by ADMINISTRATOR DECLARE TYPE Arr1 IS VARRAY(10) OF NUMBER; Tab_1 Arr1; TYPE Arr2 IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; Tab_2 Arr2; BEGIN -- Test statements here Tab_1 := Arr1(1, 3, 4, 6, 3, 2, 8, 5); FOR a IN 1 .. Tab_1.Count LOOP Dbms_Output.Put_Line(‘ ‘ || Tab_1(a)); END LOOP; Tab_2(1) := 101; Tab_2(2) := 102; Tab_2(3) := 103; Tab_2(4) := 104; FOR b IN 1 .. Tab_2.Count LOOP Dbms_Output.Put_Line(‘ ‘ || Tab_2(b)); END LOOP; END;
结果:
1 3 4 6 3 2 8 5 101 102 103 104
二维数组示例:
-- Created on 2014-5-15 by ADMINISTRATOR DECLARE -- Local variables here TYPE Array1 IS VARRAY(10) OF NUMBER; TYPE Array2 IS VARRAY(10) OF Array1; Arr Array2; BEGIN Arr := Array2(Array1(11, 12, 13, 14, 15), Array1(21, 22, 23, 24, 25)); FOR i IN 1 .. Arr.Count LOOP FOR j IN 1 .. Arr(i).Count LOOP Dbms_Output.Put_Line(Arr(i) (j)); END LOOP; END LOOP; END;
结果:
11 12 13 14 15 21 22 23 24 25
oracle 数组 array,布布扣,bubuko.com
时间: 2024-10-12 07:21:24