发表于: 2006.10.07 17:12
分类: 技术文章
出处: http://atgc.itpub.net/post/22412/217730
---------------------------------------------------------------
create or replace directory photo_dir as 'C:';
create table photos (photo BLOB);
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('PHOTO_DIR','test.jpg');
begin
insert into photos values (empty_blob())
returning photo into a_blob;
dbms_lob.fileopen(a_bfile);
dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
dbms_lob.fileclose(a_bfile);
commit;
end;
/
PL/SQL 过程已成功完成
验证是否存入了图片
select dbms_lob.getlength(photo) from photos;
DBMS_LOB.GETLENGTH(PHOTO)
-------------------------
608474











