http://www.csdn.net/expert/topic/273/273176.xml

解决方案 »

  1.   

    pl/sql有两种集合类型:索引表、嵌套表,还有变长数组
    索引表(index-by table)
    type tabletype is table of type index by binary_integer;  定义类型
    array_var tabletype ;                                     定义变量
    嵌套表(nested table)
    type tabletype is table of type;
    array_var tabletype ;                                     变长数组
    type type_name is {varray|varying array}{maximun-size} of element_type [NOT NUll];
    array_var type_name;
      

  2.   

    type a_array is varray(10) of varchar2(255);
    a a_array;
    inx pls_integer;
    begin
    --initialize the index into the array
    inx := 0;
    --initialize the array
    a := a_array();
    inx := inx + 1;
    a.extend();
    ...............
      

  3.   

    怎样用PL/SQL表实现数组功能    PL/SQL表与其他过程化语言(如C语言)的一维数组类似。实现PL/SQL表需要创建一个数据类型并另外进行变量说明。
        Type <类型名> Is
        Table Of <数据类型>
        Index by Binary_Integer;
    以下为一个例子:
    Declare
        Type Array_type is
            Table Of Number
            Index by Binary_Integer;
        My_Array Array_type;
    Begin
        For I In 1..10 Loop
            My_Array(I) := I*2;
        End Loop;
        For I In 1..10 Loop
            Dbms_Output.Put_line(To_char(My_Array(I)));
        End Loop;
    End;
      

  4.   

    怎样用PL/SQL表实现数组功能    PL/SQL表与其他过程化语言(如C语言)的一维数组类似。实现PL/SQL表需要创建一个数据类型并另外进行变量说明。
        Type <类型名> Is
        Table Of <数据类型>
        Index by Binary_Integer;
    以下为一个例子:
    Declare
        Type Array_type is
            Table Of Number
            Index by Binary_Integer;
        My_Array Array_type;
    Begin
        For I In 1..10 Loop
            My_Array(I) := I*2;
        End Loop;
        For I In 1..10 Loop
            Dbms_Output.Put_line(To_char(My_Array(I)));
        End Loop;
    End;