Link to home
Start Free TrialLog in
Avatar of pdd
pdd

asked on

Read Image from database in oracle Forms

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
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

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
Avatar of pdd
pdd

ASKER

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
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
Avatar of pdd

ASKER

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
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
Avatar of pdd

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial