码迷,mamicode.com
首页 > 数据库 > 详细

oracle 数组 array

时间:2014-05-16 02:28:48      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:数组   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,布布扣,bubuko.com

oracle 数组 array

标签:数组   array   

原文地址:http://baser.blog.51cto.com/4153192/1411997

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!