Skip to Main Content
  • Questions
  • Handling REP-0108 in Reports runtime. Returning Image based on ID

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, shahzad.

Asked: August 28, 2017 - 1:42 am UTC

Last updated: August 28, 2017 - 3:58 am UTC

Version: 10G, Reports 6i

Viewed 1000+ times

You Asked

Respected Sir,
i am facing a problem. i have folder which contains .jpg pictures of employees. and in reports i am showing their pictures against their IDs. i am using this function formula.
function CF_2Formula return Char is
 DIRX VARCHAR2(60) :='D:\Photo\';
 PIC VARCHAR2(85);
BEGIN
 PIC:=DIRX ||:StuID1||'.JPG';
  return pic;
  if length(pic) < 28 then 
   pic:=null;
   return pic;
  end if;
end;

But in folder if some employee jpg is missing. the report has stop working. and giving this error.
Rep-0108: File 'D:\Photo\132.jpg' not found.
i want this if no picture is found against employee id it will show no_image.jpg picture against missing pictures of the employee.
Please help.

and Connor said...

MOS Note 377522.1 talks about this issue. You *must* return a valid path to an image, so here is a workaround:

a) Create an image which is blank, or perhaps contains "No Employee" or something similar. This will be the image used when the one you want is not found.

b) Use TEXT_IO to test for the file in the formula code:

function CF_1Formula return varchar2 is
in_file TEXT_IO.FILE_TYPE;
filename VARCHAR2(30);

begin
  filename:= 'd:\photo\'||:nm||'.jpg' ;
  in_file := TEXT_IO.FOPEN(filename, 'r');
  TEXT_IO.FCLOSE(in_file);
  return filename;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    TEXT_IO.FCLOSE(in_file);
    return 'd:\photo\blank.jpg' ;
  WHEN OTHERS then
    return 'd:\photo\blank.jpg' ;
end;


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

thx

shahzad hasan, August 28, 2017 - 2:12 pm UTC

I solved my Problem.