Home » Developer & Programmer » Forms » Saving Excel Files as an object in oracle (DB 10g, Developer suite 10g)
Saving Excel Files as an object in oracle [message #543067] Mon, 13 February 2012 01:19 Go to next message
arkhan90
Messages: 10
Registered: April 2005
Location: karachi pakistan
Junior Member
Dear All,

How can we save Excel file as an objectin oracle. Like we can store image file. Any idea?

Thanks
Re: Saving Excel Files as an object in oracle [message #543113 is a reply to message #543067] Mon, 13 February 2012 02:48 Go to previous message
aallan
Messages: 150
Registered: October 2011
Senior Member
Hi,

you can create table as:
Create Table Email_Attachments(Id_Pk Integer Primary Key,Fname Varchar2(50),Image Blob);


then:

Create Or Replace Directory Temp As 'C:\';


then:

Create Or Replace Procedure Load_File(Pi_Id In Integer, Pfname In Varchar2) Is
Src_File Bfile;
Dst_File Blob;
Lgh_File Binary_Integer;
Begin
Src_File := Bfilename('TEMP', Pfname);
Insert Into Email_Attachments (Id_Pk,Fname,Image)
Values (Pi_Id,Pfname, Empty_Blob())
Returning Image Into Dst_File;
Dbms_Lob.Open(Src_File, Dbms_Lob.File_Readonly);
Lgh_File := Dbms_Lob.Getlength(Src_File);
Dbms_Lob.Loadfromfile(Dst_File, Src_File, Lgh_File);
Dbms_Lob.Close(Src_File);
Commit;
End 


you can test it:

Execute Load_File(1,'test.txt');
Previous Topic: download & install developer suite 6i
Next Topic: CLOB Insertion and Updation
Goto Forum:
  


Current Time: Wed Aug 21 12:35:26 CDT 2024