PL/SQL基本结构---PLSQL复合类型---记录类型record

记录类型record 
 
record类型最常用,声明的时候可以加not null,但必须给初始值,如果record类型一致可以相互赋值,如果类型不同,里面的字段恰好相同,不能互相赋值。引用记录型变量的方法是“记录变量名.基本类型变量名”。 
   ――――――――――――――――――――――――――――――――――――― 
   declare 
        type t_first is record( 
             id number(3), 
             name varchar2(20) 
        ); 
        v_first t_first; 
   begin 
      v_first.id:=1; 
      v_first.name:='cheng'; 
      dbms_output.put_line(v_first.id); 
      dbms_output.put_line(v_first.name); 
   end; 
   record类型变量间赋值 
  declare 
        type t_first is record( 
          id number, 
          name varchar2(20)    
        ); 
        v_first t_first; 
        v_second t_first; 
   begin 
        v_first.id:=1; 
        v_first.name:='susu'; 
        
        v_second:=v_first;--相互赋值 
        
        v_first.id:=2; 
        v_first.name:='kettas'; 
        dbms_output.put_line(v_first.id); 
        dbms_output.put_line(v_first.name); 
        dbms_output.put_line(v_second.id); 
        dbms_output.put_line(v_second.name); 
    end; 
    ――――――――――――

posted @ 2015-03-28 13:22  yi-  阅读(377)  评论(0编辑  收藏  举报