各位大虾,想请教一下oracle中什么时候会用自定义的record类型,如何使用?

解决方案 »

  1.   

    一般用復合數據結構時就會用到,例--顯式記錄
    set serveroutput on;
    declare 
    type eName is record(
            emp_name emp.ename%type
    );
    empName eName;
    cursor c1 is select ename from emp;
    begin
        open c1;
        loop
            fetch c1 into empName;
            exit when c1%notfound;
            dbms_output.put_line(empName.emp_name);
        end loop;
        close c1;
    end;
    /
    --隱式記錄
    declare 
        cursor c1 is select ename from emp;
    begin
        for rec in c1 loop
            dbms_output.put_line(rec.ename);
        end loop; 
    end;
    /
      

  2.   

    类似于JAVA的类,包含多个属性。
    如代表职员,需描述其诸如工号,姓名,型别,部门等等的属性。