分割Blob档案 [英] split blob file
本文介绍了分割Blob档案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从数据库中检索一些大的wave文件,并想将其分成较小的wave文件(大约5Mb)进行检索.我能怎么做?我已经看到了dbms_lob.read过程,但是此操作返回的最大文件大小为32Kb.
I need to retrieve from the database a few large wave files and would like to retrieve divided into wave files smaller (about 5Mb). How can I do? I've seen the procedure dbms_lob.read, but this return maximum file size of 32Kb.
致谢
procedure extract_blob(p_id in number, wrote_length in out number, chunk out blob) is
len_file binary_integer;
myblob blob;
myname varchar2(255);
buffer_length number := 32760;
begin
select file_wav_data, file_wav_name, dbms_lob.getlength(file_wav_data)
into myblob, myname, lun_file
from t_wav
where id = p_id;
if(len_file > wrote_length) then
dbms_lob.read(myblob,buffer_length,wrote_length+1,chunk);
wrote_length := wrote_length + buffer_length;
else wrote_length := -999; --EOF
end if;
end;
推荐答案
您可能要使用临时LOB:
You probably want to use temporary LOBs:
procedure extract_blob(
p_id in number,
offset in number,
chunk_length in out number,
chunk out blob
) is
chunk blob;
wav_data blob;
full_length number;
chunk_length number;
begin
select file_wav_data, dbms_lob.getlength(file_wav_data)
into wav_data, full_length
from t_wav
where id = p_id;
chunk_length := greatest(full_length - offset, 0);
if chunk_length = 0 then
return;
end if;
dbms_lob.createtemporary(chunk, TRUE);
dbms_lob.copy(chunk, wav_data, chunk_length, 0, offset);
end extract_blob;
如果可能的话,在处理完临时LOB(使用DBMS_LOB.FREETEMPORARY
)后,应从客户端释放该临时LOB.
If possible, you should free the temporary LOB from the client side after you have processed it (using DBMS_LOB.FREETEMPORARY
).
这篇关于分割Blob档案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文