返回类型是表类型的函数怎样调用
create or replace type obj_table as object (id number,col varchar2(100));
type table_type is table of obj_table;
function f_returntable(str in out varchar2) return table_type
as
t_1 table_type;
begin
if str is null then
return t_1;
end if;
while instr(str,',')>0 loop
t_1.extend;
t_1(t_1.count).id:=t_1.count;
t_1(t_1.count).col:=substr(str,1,instr(str,',')-1);
str:=substr(str,instr(str,','),length(str));
end loop;
t_1(t_1.count).id:=t_1.count;
t_1(t_1.count).col:=str;
return t_1;
end f_returntable;
这样调用时出错,
select * from table(mypkg.f_returntable('a,b,cc'))
ORA-00902: 无效数据类型
请问应该怎样调用返回是表类型的函数啊?
type table_type is table of obj_table;
function f_returntable(str in out varchar2) return table_type
as
t_1 table_type;
begin
if str is null then
return t_1;
end if;
while instr(str,',')>0 loop
t_1.extend;
t_1(t_1.count).id:=t_1.count;
t_1(t_1.count).col:=substr(str,1,instr(str,',')-1);
str:=substr(str,instr(str,','),length(str));
end loop;
t_1(t_1.count).id:=t_1.count;
t_1(t_1.count).col:=str;
return t_1;
end f_returntable;
这样调用时出错,
select * from table(mypkg.f_returntable('a,b,cc'))
ORA-00902: 无效数据类型
请问应该怎样调用返回是表类型的函数啊?
...全文


基础和管理
