Oracle插入Blob数据的方法
create table test20151016(a blob);
create or replace directory tmp as 'e:\';
--建立PL/SQL块
declare
b_file bfile;
b_lob blob;
begin
--return a into b_lob将该列与一个blog类型的变量绑定在一起,以后只要为b_lob赋值,即等于将该值插入了表中
insert into test20151016(a) values(empty_blob()) return a into b_lob;
--TMP是建立的文件所在的目录,一定要大写;test.png是文件名;将文件转换为bfile
b_file := bfilename('TMP', 'test.png');
dbms_lob.open(b_file, dbms_lob.file_readonly);
-- 将b_file中的内容转换到b_lob
dbms_lob.loadfromfile(b_lob,b_file,dbms_lob.getlength(b_file));
dbms_lob.close(b_file);
commit;
end;
/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29485627/viewspace-1814547/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29485627/viewspace-1814547/