Read Image from database in oracle Forms

Posted on 2006-11-27
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 ?

Question by:pdd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
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.


Author Comment

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 ?

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.

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.


Author Comment

ID: 18027867

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:

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

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

Expert Comment

by:Naveen Kumar
ID: 18028053
/* 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
tiff_image_dir VARCHAR2(80) := ’/usr/staff/photos/’;
photo_filename VARCHAR2(80);
** 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’);
MESSAGE(’This employee does not have a photo on file.’);

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

** Save the contents of an image item out to a file
** on the filesystem in a supported image format.

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.


Author Comment

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 ?

LVL 28

Accepted Solution

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 ).


Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to recover a database from a user managed backup

728 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