你能告诉我,为什么这个函数会返回一个空的 blob 值吗?它甚至不会在循环后关闭 BFILE 类型变量。我无法想象问题出在哪里。
FUNCTION f$bfile_to_blob
(I_FID_ID IN INTEGER)
RETURN BLOB IS
bf BFILE;
Amount INTEGER := 32767;
Position integer := 1;
buffer RAW(32767);
bl LONG RAW := '';
bb BLOB;
BEGIN
select fid_bckp into bf
from filedoc
where fid_id = I_FID_ID;
dbms_lob.open(bf, dbms_lob.lob_readonly);
DBMS_LOB.CREATETEMPORARY(bb, TRUE, DBMS_LOB.SESSION);
LOOP
dbms_lob.read(bf, Amount, Position, buffer);
dbms_lob.writeappend(bb,amount,buffer);
Position := Position + Amount;
END LOOP;
dbms_lob.close(bf);
return bb;
END;
我这样调用函数
select F$BFILE_TO_BLOB(fid_id) from filedoc where fid_id = 2150;