使用TABLE表达式时,对象不存在错误

时间:2015-08-16 16:58:51

标签: oracle plsql oracle11g

这是我的代码:非常直接..

create or replace package types
as
   type rec is record
   (
     employee_id NUMBER,
     fname varchar2(20)  
    );
   type tab_rec is table of rec;
   type tab_numbers is table of number;
   type tab_chars is table of varchar2(10);

 end types;
 /

 create or replace 
 function get_employees_rec
 (
   O_error_msg IN OUT varchar2,
   L_access_tab OUT types.tab_chars
   )
   return boolean
   as
--o_access_tab types.tab_chars;
cursor c_rec is 
select first_name from employees;
begin
     open c_rec;
     fetch c_rec bulk collect into L_access_tab;
     close c_rec;
     return true;
exception
when others  then
      O_error_msg:=substr(sqlerrm,1,100);
      return false;
end;

/
declare
  O_error_msg varchar2(100);
  L_access types.tab_chars;
begin
    if get_employees_rec(O_error_msg,L_access)=FALSE then
        dbms_output.put_line('Got you');
    end if;

for rec in(select * from employees e,TABLE(L_access) f where value(f)=e.first_name) 
   loop
      dbms_output.put_line(rec.first_name);
  end loop;
end;
/

但是我收到了错误:

ORA-21700:对象不存在或标记为删除 ORA-06512:第9行 21700. 00000 - "对象不存在或标记为删除" *原因:用户试图执行不适当的操作            一个不存在或标记为要删除的对象。            固定,删除和更新等操作不能            应用于不存在或标记为删除的对象。 *操作:用户需要重新初始化引用以引用            现有对象或用户需要取消标记对象。

此错误背后的原因是什么?

1 个答案:

答案 0 :(得分:0)

您无法从外部包中访问这些类型,而是将其创建为数据库对象:

create or replace type rec is object (
  employee_id NUMBER,
  fname varchar2(20));

create or replace  type tab_rec is table of rec;