Wednesday, October 21, 2009

Data Convert From a FILE to BLOB

CREATE OR REPLACE Procedure Dpr_fileToBlob(Fname in VARCHAR2, Fdir in VARCHAR2, OutBlob out BLOB)

IS

fblob BLOB;
theBFile BFILE;

Bsrc_offset NUMBER :=1;
Bdest_offset NUMBER :=1;

BEGIN

dbms_lob.createtemporary(fblob,FALSE,DBMS_LOB.SESSION);

theBFile := BFileName(Fdir,Fname);

dbms_lob.fileOpen(theBFile);

dbms_lob.loadblobfromfile(dest_lob => fblob ,
src_bfile => theBFile ,
amount => dbms_lob.getLength(theBFile),
dest_offset => Bdest_offset,
src_offset => Bsrc_offset
);

dbms_lob.fileClose(theBFile);

OutBlob := fblob;

End;
/

4 comments:

sohail.moon said...

I open the picture in form 6i with the Browse button . Sure that also open in the image field but when i commit the data that not insert inside the table ( database ) .

What is the solution for that ?
Note : I am using the Oracle Database 11g with the Form Builder 6i / 10g
Kindly guide me
sohail.moon@yahoo.com

Anonymous said...

Dear ,

I invite you to join the Global Unit
myedufaq.com
to share your knowledge with other junior students from rest of the world.

Looking for Your Favorable response.

VinothJP said...

how to read the blob content from db and to convert into file?

Tamzidul Amin said...

Dear VinthJP,

Firts you have to know the blob data format. the blob may be txt, pdf,jpg,doc or any other binary format. Then, u can open that blob file by using utlfile package with specified file format. that is, if u stored the a pdf file in blob column, u must use xxxxxx.pdf file extension. thats all.

If u have need further assistance, please call me at +8801926662229. Thanks.

Tamzidul Amin.

Post a Comment