为什么dbms_lob.fragment_insert在我的脚本中不起作用?

时间:2017-06-29 12:16:11

标签: plsql

带blob列的简单表。

create table table01 (
  myCode  VARCHAR2(10),
  myValue blob
);

insert into table01(myCode, myValue) values('abc', hextoraw('414243'));

我尝试使用dbms_lob.fragment_insert修改blob值

declare
  l_b BLOB;
begin
  SELECT myValue
  INTO l_b
  FROM table01
  WHERE myCode = 'abc'
  FOR UPDATE;

  dbms_lob.fragment_insert(l_b, 3, 1+dbms_lob.getlength(l_b), hextoraw('787878'));
end;
/

我看到如下的异常

declare
ERROR at line 1:
ORA-43856: Unsupported LOB type for SECUREFILE LOB operation
ORA-06512: at "SYS.DBMS_LOB", line 1159
ORA-06512: at line 10  
43856. 0000 -  "Unsupported LOB type for SECUREFILE LOB operation"
Document: YES
Cause:    A LOB that is not a SECUREFILE was used in a SQL statement or
          in a call where a SECUREFILE LOB was expected.
Action:   Convert the LOB to a SECUREFILE LOB or do not use this keyword
          or call.

我对Oracle DB的了解不足以理解我做错了什么。是否可以按照我尝试的方式使用dbms_lob.fragment_insert?

1 个答案:

答案 0 :(得分:0)

我的问题的答案可能是dbms_lob.fragment_insert不能用于修改未存储为安全文件的blob :(。

当我按照以下方式创建我的表时

create table table01 (
  myCode  VARCHAR2(10),
  myValue blob
) lob(myValue) store as SECUREFILE;

我的剧本有效。

可悲的是,我正在搜索pl / sql解决方案来修改大blob,而无需访问数据库主机文件系统,并且blob存储为非安全文件。我认为dbms_lob.fragment_insert可能是一个解决方案