declare
type table_emp is table of emp%rowtype
index by binary_integer;
abc table_emp;
begin
select *
into abc
from emp;
dbms_output.put_line(abc(1).mgr);
end;报错:
into abc
*
第 7 行出现错误:
ORA-06550: 第 7 行, 第 10 列:
PLS-00597: INTO 列表中的表达式 'ABC' 类型错误
ORA-06550: 第 8 行, 第 5 列:
PL/SQL: ORA-00904: : 标识符无效
ORA-06550: 第 6 行, 第 5 列:
PL/SQL: SQL Statement ignored难道into不能插入表类型?
达人赐教!
type table_emp is table of emp%rowtype
index by binary_integer;
abc table_emp;
begin
select *
into abc
from emp;
dbms_output.put_line(abc(1).mgr);
end;报错:
into abc
*
第 7 行出现错误:
ORA-06550: 第 7 行, 第 10 列:
PLS-00597: INTO 列表中的表达式 'ABC' 类型错误
ORA-06550: 第 8 行, 第 5 列:
PL/SQL: ORA-00904: : 标识符无效
ORA-06550: 第 6 行, 第 5 列:
PL/SQL: SQL Statement ignored难道into不能插入表类型?
达人赐教!
你这样使用关联数组不对,你没有指定关联数组的索引值是什么。
修改如下
declare
type table_emp is table of emp%rowtype
index by binary_integer;
abc table_emp;
begin
for(cur in select * from emp) loop
abc(cur.empno):=cur;
dbms_output.put_line(abc(1).mgr);
end loop;
end;declare
type table_emp is table of emp%rowtype
abc table_emp;
begin
select *
bulk collect into abc
from emp;
----然后再做循环。。
end;
--这里有详细的例子
http://yy-mm-dd.javaeye.com/admin/blogs/832384
type table_emp is table of emp%rowtype
index by binary_integer;
abc table_emp;
begin
forcur in (select * from emp) loop
abc(cur.empno):=cur;
dbms_output.put_line(abc(1).mgr);
end loop;
end;