1.记录类型
定义语法:
type type_name is record(field_declare[,]field_declare...);
identifier type_name
说明:type_name 为我们定义的结构体变量类型,identifier 为需要使用的结构体变量。
如:declare
type emp_record_type is record(empno emp.empno%type,ename emp.ename%type);
emp_record emp_record_type;
2.表类型
定义语法:
type table_name_type is table of element_type index by key_type;
identifier table_name_type
说明:table_name_type 用于指定索引表类型,element_type用于指定索引表元素的数据类型,key_type用于指定索引元素下标的数据类型。(注意:使用时不能直接队表变量进行赋值,要带上下标),下标类型有(Binary_integer,pls_integer,varchar2)
例如:
declare
type emp_table_type is table of emp%rowtype;
emp_table emp_table_type;
begin
select * into emp_table(-1) from emp where empno='1001';
dbsm_output.put_line(emp_table(-1).ename);
end;