【问题标题】:ORA-22275 error: invalid LOB locator specifiedORA-22275 错误: 指定的 LOB 定位器无效
【发布时间】:2012-12-08 07:57:22
【问题描述】:

我有一个用 PDF 文档填充 BLOB 变量的过程。我要做的是添加逻辑以仅在静态日期后的 60 天内显示 PDF 文档。见下文:

check_staticdate     number(1); 

function DisplayPDF (audit in number) RETURN blob is

person_id     person.person_id%type;
z_lob         blob;
blob_length   NUMBER;


CURSOR getPDF(audit number) IS
   select report
   from report_table
   where report_type = 'PDF'
   and job_no = audit order by rec_no;


begin

/* Check Valid ID */
if not package.ValidID(person_id, check_only=>TRUE) then
   return z_lob;
end if;


/* Here is the case statement.*/
select case
   when exists
      (
       SELECT 'x' from table
       where table_id = person_id
       and trunc(sysdate) < trunc(table_static_date + 60)
      )

    then 1
    else 0
   end into check_staticdate
from dual;


if (check_staticdate = 0) then
   return z_lob;
end if;



open getPDF(audit);
fetch getPDF into z_lob;
close getPDF;
return z_lob;


end DisplayPDF;

我收到的错误是:ORA-22275: invalid LOB locator specified.

我是 Oracle SQL 的新手,我不确定为什么我的 ValidID 检查通过返回 z_lob 起作用,但我的 case 语句不起作用。

编辑:添加完整的错误堆栈

Failed to execute target procedure ORA-22275: invalid LOB locator specified

ORA-06512: at "SYS.WPG_DOCLOAD", line 51

ORA-06512: at "User.Package", line 733

ORA-06512: at line 33

【问题讨论】:

    标签: sql oracle plsql oracle11g


    【解决方案1】:

    用临时优先初始化你的吊球

    DBMS_LOB.CREATETEMPORARY(z_lob,true); --true if you want it to be cached.
    

    【讨论】:

    • 我想确保您为此获得了荣誉。这最终被重新分配并重新确定了优先级。但是,您的答案最终奏效了。谢谢!
    • DBMS_LOB.OPEN 一起,像这样 - DBMS_LOB.CREATETEMPORARY( lob_loc =&gt; z_lob , cache =&gt; true , dur =&gt; dbms_lob.call); DBMS_LOB.OPEN( lob_loc =&gt; z_lob , open_mode =&gt; DBMS_LOB.LOB_READWRITE); - 它可以工作。
    【解决方案2】:

    您的函数可能会返回(取决于您的 audit 参数值)一个带有 NULL 值的 blob 到 SYS.WPG_DOCLOAD 方法,该方法会引发您看到的未处理异常。

    也许您可以将您的 return z_lob; 修改为 return nvl(z_lob, empty_blob());

    【讨论】:

      猜你喜欢
      • 2016-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多