Quantcast
Channel: Oracle Maniacs' Notes » XML Publisher Report
Viewing all articles
Browse latest Browse all 16

How to create a report with an image (.jpeg) field

$
0
0

I got a requirement from one of my clients to build a report having photograph on it. It is a report used by HR department to keep along with the personal/academic/experience records for each employee of the organization. This report was named as ‘ Employee Photograph report’.

This requirement leads me to find out the way of converting BLOB ( photographs are stored as BLOB in HR table) to CLOB and use that in a XML PUBLISHER report template.

This is how it was achieved step by step:

Write a BLOB TO CLOB converter db function as below and compile in the database. 

CREATE OR REPLACE FUNCTION APPS.getbase64( p_source BLOB )
RETURN CLOB
IS
v_result CLOB ;
BEGIN
--dbms_lob.freetemporary(v_result);
DBMS_LOB.createtemporary(lob_loc => v_result, CACHE => False, dur => 0);
Wf_Mail_Util.EncodeBLOB ( p_source, v_result);
RETURN ( v_result );
END getbase64;

Build the report and call the above BLOB to CLOB converter function from the report query as shown below:

In  my case employee photographs were stored in PER_IMAGES table in IMAGE column.

SAMPLE REPORT QUERY

——————————–

SELECT  pa.person_id
              ,pa.employee_number
              ,pa.full_name
              ,getbase64(PerImageEO.IMAGE) IMAGE1
FROM     per_all_people_f pa
              ,PER_IMAGES PerImageEO
WHERE PerImageEO.PARENT_ID=pa.employee_number

Since this is a XML publisher report I had to prepare the  template and incorporate the photograph tag  as well and below is the illustration for the same:

THE TEMPLATE

Now the IMAGE field show above is the place where the Photo of the employee should come.:

Below is the code need to put in the tag:

<?if:IMAGE1!=''?>
<fo:<span class="hiddenSpellError">instream-foreign-object</span> content-type=”image/jpg”>
<?end if?>

The ‘ IF’  clause is added to handle the employee records without photograph in the table.

Place the rdf and register as usual like any other XML publisher report.



Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>