且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Oracle 中将 CLOB 转换为 BLOB?

更新时间:2021-07-20 22:52:10

像这样的代码将执行最少的重新编码:

Code like this will perform minimal recoding:

create or replace function clob2blob(AClob CLOB) return BLOB is
  Result BLOB;
  o1 integer;
  o2 integer;
  c integer;
  w integer;
begin
  o1 := 1;
  o2 := 1;
  c := 0;
  w := 0;
  DBMS_LOB.CreateTemporary(Result, true);
  DBMS_LOB.ConvertToBlob(Result, AClob, length(AClob), o1, o2, 0, c, w);
  return(Result);
end clob2blob;
/

但是如果没有像 Base64 这样的任何编码,CLOB 无法正确包含所有图像数据

But CLOB can not properly contain all Image data without any encoding like Base64