【问题标题】:Object not exists error while using TABLE expression使用 TABLE 表达式时对象不存在错误
【发布时间】:2015-08-17 13:38:49
【问题描述】:

这是我的代码:非常直截了当..

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 - “对象不存在或被标记为删除” *原因:用户试图执行不适当的操作 不存在或标记为删除的对象。 无法进行置顶、删除、更新等操作 应用于不存在或标记为删除的对象。 *操作:用户需要重新初始化引用以引用 存在的对象或用户需要取消标记该对象。

这个错误背后的原因是什么?

【问题讨论】:

标签: oracle plsql oracle11g


【解决方案1】:

您不能像这样从外部包访问这些类型,而是将它们创建为数据库对象:

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

create or replace  type tab_rec is table of rec;

等等

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 2016-06-02
    相关资源
    最近更新 更多