Home » Developer & Programmer » Forms » Save Images in Database From Forms - Download it Here
Save Images in Database From Forms - Download it Here [message #163347] Thu, 16 March 2006 06:24 Go to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

Hi Everyone,
I have seen many times that people are confused for how to save and retrieve images in Oracle Database from forms.
Here I have created a sample form. All the coding is there. And also required scripts are also written in this post. Please download the form create the scripts and run the form.
Here we go:
Database : 9i
Forms : 6i
Create Scripts:
CREATE TABLE DOCS_COMP_DOCUMENTS
(
  DOC_ID            VARCHAR2(10),
  DOC_NAME          VARCHAR2(100),
  DOC_SCANNED_COPY  LONG RAW,
  FILE_NAME	    VARCHAR2(50),
  FILE_EXTENSION    VARCHAR2(3)
)

ALTER TABLE DOCS_COMP_DOCUMENTS ADD (
  PRIMARY KEY (DOC_ID));

CREATE OR REPLACE PROCEDURE Get_File_Name_Extension (p_path IN VARCHAR2,
                                                      p_filename OUT VARCHAR2,
                                                      p_extension OUT VARCHAR2)
IS
 v_path VARCHAR2(200);
 v_last_slash_position NUMBER;
 v_file_name VARCHAR2(30);
 v_extension VARCHAR2(4);
BEGIN
 v_path := p_path;
 v_last_slash_position := INSTR(v_path, '\', -1) + 1;
 v_file_name := SUBSTR(v_path, v_last_slash_position);
 v_extension := SUBSTR(v_path, -3);
 p_filename := upper(v_file_name);
 p_extension := upper(v_extension);
END;

Note: This Procedure is to find the file name and extension and store it as well in database. Create this procedure in database.

To retrieve images just press F7 & F8 in forms Cool

Please downlad the attached .fmb module and run it. Enjoy your time.

Thanks and Regards,
Saadat Ahmad,
saadatahmad@hotmail.com[/email] For any question regarding this module.

[Updated on: Sun, 03 January 2010 23:31] by Moderator

Report message to a moderator

Re: Save Images in Database From Forms - Download it Here [message #163484 is a reply to message #163347] Thu, 16 March 2006 21:12 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Thanks for this contribution. I will add a link to this thread from wiki in the near future.

David

[Updated on: Thu, 16 March 2006 21:13]

Report message to a moderator

Re: Save Images in Database From Forms - Download it Here [message #163621 is a reply to message #163347] Fri, 17 March 2006 09:20 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

Thanks Mr. David for the appreciation.
Saadat Ahmad
Re: Save Images in Database From Forms - Download it Here [message #220043 is a reply to message #163621] Sun, 18 February 2007 01:42 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,

The above post works in 6i forms but not in 10g forms. Though one can find out from searching how to do it in forms 10g, I have come to know by getting many messages in my email that people don't bother to search the internet. So I'm posting the solution here for 10g forms so that we can refer the person to this thread who is asking for the solution.

Thanks to orafaq also.

Please download the attached file and run the script and the form named LOAD_IMAGE_IN_10G.

Note: I got the forms from the following site and simplified it.

Thanks to François Degrelle, the author to put it on the web.You can also find other useful information here.

The address is :

http://sheikyerbouti.developpez.com/index_en/

regards,
Saadat Ahmad
Re: Save Images in Database From Forms - Download it Here [message #220129 is a reply to message #220043] Mon, 19 February 2007 00:56 Go to previous messageGo to next message
farooq112
Messages: 90
Registered: September 2006
Location: cairo
Member
thnxs ahmed
but no fount code under button
and when open form view meessage tell me cont open
program units
Re: Save Images in Database From Forms - Download it Here [message #220286 is a reply to message #220129] Tue, 20 February 2007 01:16 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,
this is the code on WHen-Button-Pressed trigger in case you can't see the code.
PROCEDURE Charge_photo 
IS

  LC$Img	Varchar2(100);  
  LN$But	Number ;
  pl_id ParamList; 
  pl_name VARCHAR2(20) := 'list_params'; 

BEGIN

	 -- Parameter list for filter --
	 pl_id := Get_Parameter_List(pl_name);
	 If NOT Id_Null(pl_id) THEN 
	 	  Destroy_Parameter_List( pl_id ) ;
	 End if ;
	 pl_id := Create_Parameter_List(pl_name); 
	 Add_Parameter(pl_id,'P_FILTRE',TEXT_PARAMETER,'*.gif,*.jpg');
	 Add_Parameter(pl_id,'P_POSY',TEXT_PARAMETER,'1');  


	 -- Selected image name --
	 :global.get_file_name := '' ;

   call_form( 'get_file_name', NO_HIDE, DO_REPLACE, QUERY_ONLY, pl_id ) ;
   if not form_success Then
   	 message('pb appel get_file_name');
   end if ;

	 If :GLOBAL.get_file_name is not null Then
	   -- reading the picture in the image item --
     LC$Img := :GLOBAL.get_file_name ;
     Go_block( 'IMAGES' );	--	Block name where image item resides
     Read_Image_File(LC$Img, 'ANY', 'IMAGES.IMAGES');	--	Give the blco and image item name

     Go_item( 'IMAGES.ID' );	--	Go to a specific field after loading the image
	 Else
	 	 Raise form_trigger_failure ;
   End if ;

END;


BTW: I compiled this form in Forms [32 Bit] Version 10.1.2.0.2 (Production)

If you have a version less than this I think it'll not show you the code.

regards,
Saadat Ahmad

[Updated on: Sun, 03 January 2010 23:34] by Moderator

Report message to a moderator

Re: Save Images in Database From Forms - Download it Here [message #411565 is a reply to message #220286] Sun, 05 July 2009 07:31 Go to previous messageGo to next message
sazzadur
Messages: 9
Registered: January 2009
Location: UK
Junior Member
I am using Form 10g R2 and database 10g. I tried with the code that you provided. But it does not work. When I select photo from source, the form does not say anyting and the form does not show photo on the screen. No sources are seemed to be error free.
Re: Save Images in Database From Forms - Download it Here [message #411676 is a reply to message #220043] Mon, 06 July 2009 05:39 Go to previous messageGo to next message
sazzadur
Messages: 9
Registered: January 2009
Location: UK
Junior Member
I tried to work in your attached image solution forms. It did not work perfectly. The REP item does not show the full file name, so when I try to load the file, the system can not find the file. It does not show the full file name, it shows few character with the file extension. For example, if the file name is 'oracle.tif', it only shows 'cle.tif'. What is the problem?
Re: Save Images in Database From Forms - Download it Here [message #411726 is a reply to message #411676] Mon, 06 July 2009 08:18 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,
Provide the screenshot of your problem. I downloaded the forms both for 6i and 10g and both just works fine. Have you compiled the form GET_FILE_NAME in 10g?
Re: Save Images in Database From Forms - Download it Here [message #411738 is a reply to message #411726] Mon, 06 July 2009 08:56 Go to previous messageGo to next message
sazzadur
Messages: 9
Registered: January 2009
Location: UK
Junior Member
Yes, I compiled. It works but when I try to browse files, the list does not show the full file name. So when I select any image file, it can not find the file because the form does not show the full name. I attach here the screen shot.
If you see the screen shot, you can see the last 4 files. The original files name are Blue hills, sunset, water lilies and winter. But the form shows e hills, set, er lilies and ter.
What is the problem?
Re: Save Images in Database From Forms - Download it Here [message #411758 is a reply to message #163347] Mon, 06 July 2009 10:35 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
Respected Sir,

When i want to open GET_FILE_NAME.fmb and Load_Image_in_10g.fmb forms in Oracle 10g Form Developer its shows error "PDE-PEP006 Encoded Program unit has an known format" please help me how i can open these forms in Oracle 10g developer.

[Updated on: Mon, 06 July 2009 10:36]

Report message to a moderator

Re: Save Images in Database From Forms - Download it Here [message #411765 is a reply to message #163347] Mon, 06 July 2009 11:14 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
Sir,

Please compile GET_FILE_NAME.fmb form in Oracle 10g form developer and then upload it or please upload all codes of this form that you write on button, triggers, procedures please i need GET_FILE_NAME.fmb form urgently

i am using Oracle 10g form Developer 32bit and Oracle 10g Database Express
Re: Save Images in Database From Forms - Download it Here [message #411771 is a reply to message #411738] Mon, 06 July 2009 12:19 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,
which version of forms you have? I have
Forms [32 Bit] Version 10.1.2.0.2 (Production)

I download the same form again which I iploaded and run it. It displays full image name and runs successfully.

Check the attached image.
./fa/6475/0/
Re: Save Images in Database From Forms - Download it Here [message #411772 is a reply to message #411765] Mon, 06 July 2009 12:22 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

Shaheer!
which forms version you are using? I wrote my version in previous post.
Re: Save Images in Database From Forms - Download it Here [message #411775 is a reply to message #411772] Mon, 06 July 2009 12:48 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
Sir,

I am using Oracle 10g Forms [32 Bit] Version 9.0.4.0.19 (Production)and Oracle 10g Database Express Edition.
Re: Save Images in Database From Forms - Download it Here [message #411779 is a reply to message #411775] Mon, 06 July 2009 12:53 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

I'm using Forms [32 Bit] Version 10.1.2.0.2 (Production)
Sorry you cannot compile this form with your forms verion. Upgrade your form version to compile this code.
Re: Save Images in Database From Forms - Download it Here [message #411781 is a reply to message #411779] Mon, 06 July 2009 13:10 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member

Thanks for guide me.
Re: Save Images in Database From Forms - Download it Here [message #411784 is a reply to message #411771] Mon, 06 July 2009 13:26 Go to previous messageGo to next message
sazzadur
Messages: 9
Registered: January 2009
Location: UK
Junior Member
I use the same version as you, Forms [32 Bit] Version 10.1.2.0.2 (Production). Its very interesting that I never get the full file name. I can not understand whats the problem.

[Updated on: Mon, 06 July 2009 13:27]

Report message to a moderator

Re: Save Images in Database From Forms - Download it Here [message #412319 is a reply to message #411784] Wed, 08 July 2009 11:53 Go to previous messageGo to next message
mobs
Messages: 1
Registered: July 2009
Location: Mérida
Junior Member
I´m running forms in linux, and then nothing appears.
Re: Save Images in Database From Forms - Download it Here [message #412455 is a reply to message #412319] Thu, 09 July 2009 08:31 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

It works on windows. If you want to run it against Linux, change the code. Source code is provided in this post.

regards,
Saadat Ahmad
Re: Save Images in Database From Forms - Download it Here [message #412793 is a reply to message #163347] Sat, 11 July 2009 22:54 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
Sir,

i am facing a problem, i compiled both forms in 10g Release 2 (10.1.2.0.2). when i click on the browse button an error occur (FRM-40010: cannot read from file get_file_name). please help me.
Please the attached image
  • Attachment: help.JPG
    (Size: 39.10KB, Downloaded 1071 times)
Re: Save Images in Database From Forms - Download it Here [message #412807 is a reply to message #412793] Sun, 12 July 2009 04:49 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

The message itself is telling you the problem. Either you don't have get_file_name form in your form's path or you didn't compile it. From where you are opening the get_file_name form?
Copy it to the folder \DevSuiteHome_1\forms (Your forms 10g Home), open it in form builder, press ctrl+shift+k and then ctrl+t. Try again.
Re: Save Images in Database From Forms - Download it Here [message #413408 is a reply to message #412807] Wed, 15 July 2009 10:31 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
thanks for guide
Re: Save Images in Database From Forms - Download it Here [message #413413 is a reply to message #163347] Wed, 15 July 2009 11:05 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
Sir,

Thanks for providing these forms, i use these forms in my project and its work fine. Picture load properly in Image item. I create a Save Button in my form, Now i want WHEN BUTTON IS PRESSED picture save into database. please help me what can i do that the given insert statement execute properly.


insert into employee_table (emp_pic) values ...............


Re: Save Images in Database From Forms - Download it Here [message #413440 is a reply to message #412807] Wed, 15 July 2009 12:49 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

you don't need to do anything because form is doing everything for you. After uploading the image, just save it from the toolbar. Or in the button just write
commit_form;

Just like a normal record. You can query the images and id's as well just like a normal record.
Re: Save Images in Database From Forms - Download it Here [message #413458 is a reply to message #163347] Wed, 15 July 2009 18:47 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
thanks again
Re: Save Images in Database From Forms - Download it Here [message #415059 is a reply to message #413440] Fri, 24 July 2009 10:14 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
hi,

Please tell me how to retrieve save image from database into image text item. please help me.

Re: Save Images in Database From Forms - Download it Here [message #415062 is a reply to message #415059] Fri, 24 July 2009 10:19 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

F7 then F8
Re: Save Images in Database From Forms - Download it Here [message #415072 is a reply to message #415062] Fri, 24 July 2009 10:57 Go to previous messageGo to next message
Shaheer
Messages: 50
Registered: June 2008
Location: Pakistan
Member
F7 and F8 not work for me please help me.

I create a form which contains many fields such as Passport No. Gamca No. Sr. No. etc as shown in upload picture. Picture and other field's data save into database properly but when I want to retrieve stored data and stored picture only data is retrieve, picture is not retrieve.

I use WHEN-VALIDATE-ITEM trigger on Passport No. text item field and using SELECT statement to retrieve data from the database into form. Please help me how to use select statement to retrieve picture into form.

  • Attachment: myp.JPG
    (Size: 45.08KB, Downloaded 1111 times)
Re: Save Images in Database From Forms - Download it Here [message #415267 is a reply to message #415072] Mon, 27 July 2009 00:01 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Use Post-Query to get the image when retrieving records.

David
Re: Save Images in Database From Forms - Download it Here [message #415331 is a reply to message #163347] Mon, 27 July 2009 05:09 Go to previous messageGo to next message
shahzaib_4vip@hotmail.com
Messages: 376
Registered: December 2008
Location: karachi
Senior Member
Well how to store image with Blob, Long Raw take lot of time to run in report when picture exceed 10 to 15

Please upload a example with Blob Field


Regards


Shahzaib ismail
Re: Save Images in Database From Forms - Download it Here [message #415435 is a reply to message #415331] Mon, 27 July 2009 18:50 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
This is the Forms forum, not the Reports forum. Search in that forum.

There are sample forms already in the forum, all you have to do is search and look.

David
Re: Save Images in Database From Forms - Download it Here [message #426601 is a reply to message #163347] Fri, 16 October 2009 18:31 Go to previous messageGo to next message
scotch999
Messages: 2
Registered: October 2009
Junior Member
Excellent sample form and proc/table, but not working in my case when we have a BLOB datatype in the table (can't use LONG RAW) and Appserver in 9i R1 and database is 10gR2. For other combinations i.e. higer appserver or lower database version it still works.

In above combination it returns following error on query:

FRM-40505: ORACLE error: unable to performe query

display error->

SELECT ROWID,DOC_ID,DOC_NAME,DOC_SCANNED_COPY,FILE_NAME,FILE_EXTENSION FROM DOCS_COMP_DOCUMENTS

ORA-00932: inconsistent datatypes: expected got


Any workaround/solution without changing database column from BLOB to LONG RAW?

thanks
Re: Save Images in Database From Forms - Download it Here [message #426667 is a reply to message #426601] Sun, 18 October 2009 08:31 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,

I think it's because of your verison otherwise, it works fine with BLOB data type.

regards,
Saadat Ahmad
Re: Save Images in Database From Forms - Download it Here [message #426808 is a reply to message #426667] Mon, 19 October 2009 19:50 Go to previous messageGo to next message
scotch999
Messages: 2
Registered: October 2009
Junior Member
Yes, you are right, version is the problem. In fact just that combination of Application server and Databse Version.

I can't go back to Oracle for this problem because 9i Release 1 AppSrvr is desupported long time ago. Therefore, I put a post there in case somebody knows a work-around or a solution.


Actually, one of our customer is having this problem. Already suggested them to upgrade their Oracle Appserver, but its up to them to listen to our advise or keep pushing us for a fix Smile

Re: Save Images in Database From Forms - Download it Here [message #433302 is a reply to message #220043] Tue, 01 December 2009 05:57 Go to previous messageGo to next message
deeneshjoshi
Messages: 3
Registered: November 2009
Location: Hyderabad, India
Junior Member
The file that you had attached long before(on 6th july 2009) doesnot upload jpg files that are greater than 800 kb. Can you check that. I am using forms 10g.

Rest, your application works good. If it can work for jpg files greater than 800kb then I would definetly say you are great
Re: Save Images in Database From Forms - Download it Here [message #439229 is a reply to message #411784] Fri, 15 January 2010 01:49 Go to previous messageGo to next message
m.f.nasir
Messages: 2
Registered: January 2010
Location: MALAYSIA
Junior Member
sazzadur wrote on Tue, 07 July 2009 02:26
I use the same version as you, Forms [32 Bit] Version 10.1.2.0.2 (Production). Its very interesting that I never get the full file name. I can not understand whats the problem.


first post, first newbie question..
how to update it...? Razz
Re: Save Images in Database From Forms - Download it Here [message #444754 is a reply to message #439229] Tue, 23 February 2010 23:27 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Sorry that I have been so long in replying.

How to update ... what???

David
Re: Save Images in Database From Forms - Download it Here [message #449570 is a reply to message #444754] Tue, 30 March 2010 10:01 Go to previous messageGo to next message
jpatpatia
Messages: 1
Registered: March 2010
Location: Minneapolis
Junior Member
Hi Saadat,
Thanks for the post. The form works on the client without any problems, but I work with Oracle Aplications (EBS) and in the 11i version, everything is based on the server (Unix in my case).
I would like to be able to get the images from the client (Windows) to be loaded on the forms running on the servers.
Is there a way to that...
Thanks
JP
Re: Save Images in Database From Forms - Download it Here [message #453198 is a reply to message #220043] Tue, 27 April 2010 17:14 Go to previous messageGo to previous message
leenaree
Messages: 1
Registered: April 2010
Junior Member
Thank you for your contributions to this thread.
What kind of file is ".rar" and how do I open it?

Thank you,
Eileen
Previous Topic: read, display and store image file in database
Next Topic: form not showing in IE11 browser
Goto Forum:
  


Current Time: Mon Sep 26 09:24:03 CDT 2016

Total time taken to generate the page: 0.14325 seconds