Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3257
  • Last Modified:

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
0
pdd
Asked:
pdd
  • 4
  • 3
1 Solution
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
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
 
pddAuthor Commented:
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
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
pddAuthor Commented:
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
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
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
 
pddAuthor Commented:
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
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now