关于 is table of的有关问题
关于 is table of的问题
type emp_table_type is table emp%rowtype index by binary_integer;
type ename_table_type is table of emp.ename%type;
为什么上面那句没有of,而下面那句没有 index by binary_integer?
------解决方案--------------------
举个例子来说下你就明白了:
type emp_table_type is table emp%rowtype index by binary_integer;
type ename_table_type is table of emp.ename%type;
为什么上面那句没有of,而下面那句没有 index by binary_integer?
------解决方案--------------------
举个例子来说下你就明白了:
- SQL code
declare type emp_table_type is table of emp%rowtype index by binary_integer;--这是类型声明 type ename_table_type is table of emp.ename%type;--这是类型声明 emp_table emp_table_type;--这里是定义变量 ename_table ename_table_type;--这里是定义变量 begin --没有index by需要初始化才能使用,否则会报错:变量未初始化 ename_table:= ename_table_type(); for v_ind in 1..20 loop ename_table.extend;--每次添加元素都要extend ename_table.(v_ind):='Ename' || v_ind; --index by只要定义就可以直接用,无需初始化 emp_table(v_ind).ename:='Ename' || v_ind; emp_table(v_ind).sal:=1000* v_ind; end loop; end;