我有一个Oracle对象类型的层次结构,例如:
parent_t
child_1_t under parent_t
child_2_t under parent_t我还有一个parent_t对象的集合类型:
col_t is table of parent_t以及一个返回此集合的函数。返回的集合可能包含child_1_t或child_2_t对象。
如果这样调用,这在PL/SQL中工作得很好:
l_col := fun();
-- process l_col但是,如果从SQL调用:
select * from table(fun());我得到ORA-21700:对象不存在或被标记为删除。
如果我将函数的签名更改为仅返回子对象的集合,则一切正常。
有没有办法让它在SQL中使用父对象集合的签名?
发布于 2015-11-16 18:16:28
我为您描述的场景创建了一个快速测试脚本,它按预期工作。也许你的函数或类型有问题,我希望这个工作脚本能帮助你
select * from table(my_foo);
ID
1 1
2 2
create or replace type parent_t as object(
id int
) not final;
create or replace type child_1_t under parent_t
(name varchar2(10));
create or replace type child_2_t under parent_t
(descr varchar2(10));
create or replace type collection_parent_t as table of parent_t;
create or replace function my_foo return collection_parent_t
as
t1 child_1_t;
t2 child_2_t;
res collection_parent_t := collection_parent_t();
begin
t1 := child_1_t(1, '1');
t2 := child_2_t(2, '2');
res.extend;
res(res.count) := t1;
res.extend;
res(res.count) := t2;
return res;
end;发布于 2015-11-16 19:42:48
似乎我遇到了这些问题,因为我的对象类型在某种程度上被破坏了。我删除了类型,重新创建了它们,现在一切都像预期的那样工作。
https://stackoverflow.com/questions/33730704
复制相似问题