To add further to my earlier post Display image using Reports 6i, here we will discuss how to display image when file path is stored in the table. In our example the file directory is a constant directory and only the file name is stored in the table.
The person requested this post had following problem
1) Need to store image in one of the directory and display that using Reports 6i
2) If file does not exists in the directory, the report should complete normal and do not display any image
3) Psuedo code
If file exists then
display image
else
display blank (no image)
end if;
Most of the steps discussed in earlier post are same with few changes as follows
Create a new formula column say CF_URL and write following code in the format trigger
function CF_URLFormula return Char is
v_handle utl_file.file_type;
v_file_dir VARCHAR2(60) := '/u002/app/applmgr/temp/';
begin
-- The UTL_FILE is used to check if the file exists in the directory.
-- If it is unable to open the file then an exception will thrown.
-- We will catch the exception and return null as the final URL.
-- Without this exception for any invalid path, the report will error out
-- and not work as expected.
v_handle := utl_file.fopen(v_file_dir, :photo_name, 'R');
utl_file.fclose(v_handle);
RETURN v_file_dir||:photo_name;
exception
when others then
srw.message(100,SQLERRM);
return null;
end;
Another change is in the layout. Screenshot below
Related Post:
Display image using Reports 6i
Insert BLOB Image file into Oracle Database Table