Home » Developer & Programmer » Forms » Storing an Image File in Oracle 8i and retrieving onto a Form
Storing an Image File in Oracle 8i and retrieving onto a Form [message #78571] Mon, 04 March 2002 03:02 Go to next message
Stuart Shepherd
Messages: 6
Registered: January 2002
Junior Member
I am new to Oracle Forms and need some advice on storing an image (.gif, .jpg, .bmp files) in the database. Ideally I would like to allow the user to save the image into the database via a form and then be able to view the stored images on another form. I need to associate the image with an id from another table.

I have read around on the internet but cannot find much help on this. I could really do with an example of a similar solution to this. I don't mind whether the image itself is stored in the database or just the file name of the image, i just need a simple quick solution.

Can anyone help me on this?

Any help will be much appreciated, I'm desperate!

Regards

Stuart Shepherd
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #78574 is a reply to message #78571] Mon, 04 March 2002 03:14 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
1 create table like this
create table imagetest
(image_id number,
image blob);
2.in form create base table block from imagetest
3.the field image should be of type "image"
4.user read_image_file built in to read file to the the fied image and save
5. to read the image from the database , simply execute query on the block
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #78576 is a reply to message #78571] Mon, 04 March 2002 03:30 Go to previous messageGo to next message
Stuart Shepherd
Messages: 6
Registered: January 2002
Junior Member
Thanks for a swift response!

How I select the file from windows? Do i not have to enter the filename? Will the form do the insert for me?

Regards

Stuart
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #78584 is a reply to message #78576] Mon, 04 March 2002 13:36 Go to previous messageGo to next message
Stuart Shepherd
Messages: 6
Registered: January 2002
Junior Member
Hi Pratap,

Thanks for you help on this matter it has been extremely helpful!

I have managed to read the image onto the form and save it into the database via the save icon in forms runtime toolbar.

If I want to add a button onto my form to allow the user to save/insert the image to the database table, what is the insert statement that I should use?

I have tried a standard insert, but it didn’t like the BLOB file. Can you give me an example of the code needed to save an image into the database via a form (6i)?

Any help on this will be greatly appreciated!

Regards

Stuart Shepherd
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #78589 is a reply to message #78576] Mon, 04 March 2002 23:53 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
here is an example

SQL> desc blobs
Name Null? Type
------------------------------- -------- ----
ID VARCHAR2(255)
BLOB_COL BLOB

create directory My_files as 'c:temp';

procedure insert_img as
f_lob bfile;
b_lob blob;
begin
insert into blobs values ( 'MyGif', empty_blob() )
return blob_col into b_lob;
f_lob := bfilename( 'MY_FILES', 'c:tempemail.gif' );
dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
commit;
end;
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #78598 is a reply to message #78576] Tue, 05 March 2002 01:00 Go to previous messageGo to next message
Stuart Shepherd
Messages: 6
Registered: January 2002
Junior Member
Hi Pratap,

Will this insert work through an oracle form?

I get a error message about the return statement.

'return blob_col into b_lob;'

Should I put this insert into the trigger or call a program unit?

Regards

Stuart Shepherd
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #80075 is a reply to message #78571] Fri, 09 August 2002 02:22 Go to previous messageGo to next message
Thomas Pöhler
Messages: 1
Registered: August 2002
Junior Member
How can you migrate this straightforward solution to web forms?

br
Thomas
Re: Storing an Image File in Oracle 8i and retrieving onto a Form [message #81380 is a reply to message #78571] Wed, 12 February 2003 06:26 Go to previous message
ezhilan
Messages: 5
Registered: February 2003
Junior Member
Sir,
I would also like to know
"how to store an image and retrieve it in a form using oracle" using VB
Previous Topic: Creation of zip file
Next Topic: Developer with Report 2.5.5.22.0 needed
Goto Forum:
  


Current Time: Thu Mar 28 04:54:53 CDT 2024