1.基于表的记录类型
student_record student%rowtype;
其中student是一张表,申明student_record记录后,该结构和student具有一致的结构
2.基于游标的记录类型
declare --游标 cursor students_cursor is select * from student; --声明基于游标的记录 student_record students_couror%rowtype; --定义游标变量类型 type students_cursor is ref cursor return student%rowtype; --申明游标变量 student_cur_var student_cursor; --声明基于游标变量的记录 student_cur_record student_cur_var%rowtype;
students_cursor 是一个显示游标,oracle允许您通过在显示游标或游标变量加上%rowtype的方法来声明一个基于游标的变量.
3.自定义记录类型
可以用type ... is record的语句来定义记录类型,然后声明一个记录.
declare type student_rt is record( id student.id type, name student.name%type, total number(5,2) ); student_record student_rt;