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.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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.  …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

749 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