oracle 数组 array

一维数组示例如下:


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




本文出自 “路漫漫其修远兮…” 博客,请务必保留此出处http://baser.blog.51cto.com/4153192/1411997

oracle 数组 array,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。