首先,insert into后面只能跟表,不能跟别的对象 其次,select * from test2返回的是一组记录,而rs是一个数组,每个元素为obj_table类型。不能直接select into 给它create or replace function f_normal(s int) return t_table as type t_table1 is table of test2%rowtype; rs t_table1; begin select * bulk collect into rs from test2; return null; end f_normal; /如果要将test2里的值赋给数组,就得用游标一一赋值 create or replace function f_normal(s int) return t_table as rs t_table:=t_table(); i integer:=0; begin for x in(select * from test2)loop i:=i+1; rs.extend; rs(i):=obj_table(x.id1,x.name1); end loop; return rs; end f_normal; /此时函数创建成功,可以用table()函数直接查看它的值 select * from table(f_normal(null));
其次,select * from test2返回的是一组记录,而rs是一个数组,每个元素为obj_table类型。不能直接select into 给它create or replace function f_normal(s int)
return t_table
as
type t_table1 is table of test2%rowtype;
rs t_table1;
begin
select * bulk collect into rs from test2;
return null;
end f_normal;
/如果要将test2里的值赋给数组,就得用游标一一赋值
create or replace function f_normal(s int)
return t_table
as
rs t_table:=t_table();
i integer:=0;
begin
for x in(select * from test2)loop
i:=i+1;
rs.extend;
rs(i):=obj_table(x.id1,x.name1);
end loop;
return rs;
end f_normal;
/此时函数创建成功,可以用table()函数直接查看它的值
select * from table(f_normal(null));