Save Images in Database From Forms - Download it Here [message #163347] |
Thu, 16 March 2006 06:24 |
|
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
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 #220286 is a reply to message #220129] |
Tue, 20 February 2007 01:16 |
|
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 #411676 is a reply to message #220043] |
Mon, 06 July 2009 05:39 |
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 #411738 is a reply to message #411726] |
Mon, 06 July 2009 08:56 |
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 #411765 is a reply to message #163347] |
Mon, 06 July 2009 11:14 |
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 #413413 is a reply to message #163347] |
Wed, 15 July 2009 11:05 |
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 #426601 is a reply to message #163347] |
Fri, 16 October 2009 18:31 |
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 #433302 is a reply to message #220043] |
Tue, 01 December 2009 05:57 |
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 #449570 is a reply to message #444754] |
Tue, 30 March 2010 10:01 |
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
|
|
|
|