Type Syncdata Is Table Of Varchar2(4000) Index By Varchar2(64);
上面这个是啥意思?解释一下
 还有TYPE的基本应用

解决方案 »

  1.   

    定义一个联合数组,
    Table Of Varchar2(4000)是数组存在数据的类型,
    Index By Varchar2(64)是数组下标的类型。
      

  2.   

    TYPE 说明后面是你的自定义类型。
      

  3.   

    type本身是自定义数据类型。
    Type Syncdata Is Table Of Varchar2(4000) Index By Varchar2(64);
    TABLE 相当于是数组,这里定义了一个数组类型Syncdata
    INDEX BY Varchar2(64);这里是定义数组下标是整数,因为ORACLE中下标可以是字符串.
     VARCHAR2(4000)这是定义数组里面只能放字符串
      

  4.   


    SQL> 
    SQL> declare
      2    current varchar2(9 char);
      3    element integer;
      4    type months_varray is varray(12) of string(9 char);--
      5    type calender_table is table of varchar2(9 char)--
      6         index by varchar2(9 char);
      7    month months_varray :=
      8          months_varray('January','February','March','April'
      9                        ,'May','June','July','August','September'
     10                        ,'October','November','December');
     11    calendar calender_table;
     12  begin
     13    if calendar.count=0 then
     14       dbms_output.put_line('Assignment loop:');
     15       dbms_output.put_line('----------------');
     16       for i in month.first..month.last loop
     17           calendar(month(i)) := to_char(i);
     18           dbms_output.put_line('Index ['||month(i)||'] is ['||i||']');
     19       end loop;
     20       dbms_output.put(chr(10));
     21       dbms_output.put_line('Post-assignment loop:');
     22       dbms_output.put_line('----------------');
     23       for i in 1..calendar.count loop
     24           if i=1 then
     25              current := calendar.first;
     26              element := calendar(current);
     27           else
     28               if calendar.next(current) is not null then
     29                  current := calendar.next(current);
     30                  element := calendar(current);
     31               else
     32                   exit;
     33               end if;
     34           end if;
     35       dbms_output.put_line('Index ['||current||'] is ['||element||']');
     36       end loop;
     37    end if;
     38  end;
     39  /
     
    PL/SQL procedure successfully completed
     
    SQL> set serveroutput on;
    SQL> /
     
    Assignment loop:
    ----------------
    Index [January] is [1]
    Index [February] is [2]
    Index [March] is [3]
    Index [April] is [4]
    Index [May] is [5]
    Index [June] is [6]
    Index [July] is [7]
    Index [August] is [8]
    Index [September] is [9]
    Index [October] is [10]
    Index [November] is [11]
    Index [December] is [12]Post-assignment loop:
    ----------------
    Index [April] is [4]
    Index [August] is [8]
    Index [December] is [12]
    Index [February] is [2]
    Index [January] is [1]
    Index [July] is [7]
    Index [June] is [6]
    Index [March] is [3]
    Index [May] is [5]
    Index [November] is [11]
    Index [October] is [10]
    Index [September] is [9]
     
    PL/SQL procedure successfully completed
     
    SQL>