Tuesday, October 28, 2014

How to Read Image / Picture in Oracle Reports from File System ?

As salamualikum (islamic greetings), brothers and sisters. :)
Hope you are well with the grace of Almighty Allah (swt).

Today, i discuss an important issue, many of oracle developer spend hours and hours to make a reports to show image from file system, which is much complex.

From Now on, it will be easy and remain easy. :)

Follow the bellow steps.

  1. Take a Formula column
  2. Data Type Char
  3. Length 500
  4. Set READ FROM FILE property to YES
  5. Set File Format to Image
  6. Make the Image stored folder as Shared Folder

Example Code::

function CF_IMAGEFormula return Char is
  
  filename VARCHAR2(200);
  tiff_image_dir VARCHAR2(80) :='<PC_NAME>/emp_picture/'; --// Folder name should be shared for shared link.
    out_file Text_IO.File_Type;
BEGIN

out_file :=Text_IO.Fopen(tiff_image_dir||:EMP_CODE||'.jpg', 'r'); -- r is read only AND EMP_CODE is the name of image.

filename := tiff_image_dir||:EMP_CODE||'.jpg';
return filename;

exception
when no_data_found then
RETURN tiff_image_dir||'blank.jpg';

when others then
if sqlcode=-302000 then
RETURN tiff_image_dir||'blank.jpg';
end if; 

end;


 You are Done :)
Pray for me to Almighty Allah (swt) to keep it up and for my hereafter.

No comments:

Post a Comment