Solved

Read Image from database in oracle Forms

Posted on 2006-11-27
9
2,734 Views
Last Modified: 2008-01-09
Hi experts


I have 2 form.
One that read an image file and insert it into a long raw.
This work ok.

But now i want to display the image from the database into the second form.

How can i do this ?

Thanks
0
Comment
Question by:pdd
  • 4
  • 3
9 Comments
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 18020511
You have to use image control in the layout editor.

as far as I remember this image control will be linked to that field in the database. If not, then we will use a image builtin to load the image in some trigger like post-record or any trigger after fetching the data from the database as per your needs.

read_image_file(..) builtin is one example.

for more info. refer to forms manual for more image builtins with which you should be able to do it.

Thanks
0
 
LVL 4

Author Comment

by:pdd
ID: 18027608
I've just checked and the pictures do not get inserted into the database.

In the inseration form I have a text field where i enter the image path and a picture item. When i press a button it executes

read_image_file( :POZE_PILOTI.fisier, 'JPG', 'POZE_PILOTI.POZA' );

witch displays the picture in the image item.

But when i press F10 the insert is done, but the long raw column (poza) is empty.

How can i insert the picture intro the database ?

Thanks
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 18027701
but initially your question was how to read from the database and display it. That is why i gave that update.

If you want to save it in your db,

Run your form and once it opens, give right mouse click and just look for an option something like 'insert image/insert picture/or somethign of that sort' but i dont remember the exact option now. Once this is done, just save it in the usual way as you save normal record.

I am sure there is an option in the right mouse click because i have done it myself.

Thanks
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Author Comment

by:pdd
ID: 18027867
OK

I've inserted a picture into the database using a PL/SQL Developer.

Now, How do i display the image from the database into a form.

In the form I have A button. When I click it it fires this trigger:

DECLARE
   poza LONG RAW;
BEGIN
   select poza INTO poza from poze_piloti where id=50;
   read_image_file( poza, 'JPG', ':POZE_PILOTI.poza');
END;


This does not work.
The first parameter in read_image_file is filename
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 18028053
READ_IMAGE_FILE examples
/* Read an image from the filesystem into an image item on the
** form. In this example, the scanned picture identification
** for each employee is NOT saved to the database, but is
** stored on the filesystem. An employee’s photo is a TIFF
** image stored in a file named <Userid>.TIF Each employee’s
** Userid is unique.
** trigger: Post-Query
*/
DECLARE
tiff_image_dir VARCHAR2(80) := ’/usr/staff/photos/’;
photo_filename VARCHAR2(80);
332
BEGIN
/*
** Set the message level high so we can gracefully handle
** an error reading the file if it occurs
*/
:System.Message_Level := ’25’;
/*
** After fetching an employee record, take the employee’s
** Userid and concatenate the ’.TIF’ extension to derive
** the filename from which to load the TIFF image. The EMP
** record has a non-database image item named ’EMP_PHOTO’
** into which we read the image.
*/
photo_filename := tiff_image_dir||LOWER(:emp.userid)||’.tif’;
/*
** For example ’photo_filename’ might look like:
**
** /usr/staff/photos/jgetty.tif
** ------
**
** Now, read in the appropriate image.
*/
READ_IMAGE_FILE(photo_filename, ’TIFF’, ’emp.emp_photo’);
IF NOT FORM_SUCCESS THEN
MESSAGE(’This employee does not have a photo on file.’);
END IF;
:SYSTEM.MESSAGE_LEVEL := ’0’;
END;

the above is to read the file from file system and show it in the image control.

==================================================================
/* Built-in: WRITE_IMAGE_FILE
**
** Save the contents of an image item out to a file
** on the filesystem in a supported image format.
*/
BEGIN
WRITE_IMAGE_FILE(’output.tif’,
’TIFF’,
’emp.photo_image_data’,
maximize_compression,
original_depth);
END;

this is to write the image displayed in the forms back to OS file.

But since you need it to retrieve from database, is this item a base table item or control item.

If this a base table item, just by scrolling from one record to other should display the image right ? because this control is mapped to that field in the database right.

Thanks
0
 
LVL 4

Author Comment

by:pdd
ID: 18028921
what you sent me is the help from from builder and i've already read that.

After I use READ_IMAGE_FILE the data isn't saved into the database when I press F10.

Cold you make an example for me to download ?

Thanks
0
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 250 total points
ID: 18029013
yes, i gave it from the reference only because i am not working on forms now.

"But since you need it to retrieve from database, is this item a base table item or control item.
If this a base table item, just by scrolling from one record to other should display the image right ? because this control is mapped to that field in the database right. "  -- no comments for this from you ?

let me be clear:
--------------------
to save a picture into db : i have used right mouse click option and did it.
to get that back and display it : i think it was a base table item and i got it automatically i think.

as i have given already above from the reference ( to save and read from OS files and NOT from database ).

Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question